Commit 7fc7af64 authored by Yong Zhi's avatar Yong Zhi Committed by Mauro Carvalho Chehab

media: staging/intel-ipu3: Add imgu top level pci device driver

This patch adds support for the Intel IPU v3 as found
on Skylake and Kaby Lake SoCs.

The driver glues v4l2, css(camera sub system) and other
pieces together to perform its functions, it also loads
the IPU3 firmware binary as part of its initialization.
Signed-off-by: default avatarYong Zhi <yong.zhi@intel.com>
Signed-off-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent a0ca1627
......@@ -39,4 +39,6 @@ source "drivers/staging/media/tegra-vde/Kconfig"
source "drivers/staging/media/zoran/Kconfig"
source "drivers/staging/media/ipu3/Kconfig"
endif
......@@ -9,3 +9,4 @@ obj-$(CONFIG_VIDEO_SUNXI) += sunxi/
obj-$(CONFIG_TEGRA_VDE) += tegra-vde/
obj-$(CONFIG_VIDEO_ZORAN) += zoran/
obj-$(CONFIG_VIDEO_ROCKCHIP_VPU) += rockchip/vpu/
obj-$(CONFIG_VIDEO_IPU3_IMGU) += ipu3/
config VIDEO_IPU3_IMGU
tristate "Intel ipu3-imgu driver"
depends on PCI && VIDEO_V4L2
depends on MEDIA_CONTROLLER && VIDEO_V4L2_SUBDEV_API
depends on X86
select IOMMU_IOVA
select VIDEOBUF2_DMA_SG
---help---
This is the Video4Linux2 driver for Intel IPU3 image processing unit,
found in Intel Skylake and Kaby Lake SoCs and used for processing
images and video.
Say Y or M here if you have a Skylake/Kaby Lake SoC with a MIPI
camera. The module will be called ipu3-imgu.
#
# Makefile for the IPU3 ImgU drivers
#
ipu3-imgu-objs += \
ipu3-mmu.o ipu3-dmamap.o \
ipu3-tables.o ipu3-css-pool.o \
ipu3-css-fw.o ipu3-css-params.o \
ipu3-css.o ipu3-v4l2.o ipu3.o
obj-$(CONFIG_VIDEO_IPU3_IMGU) += ipu3-imgu.o
This is a list of things that need to be done to get this driver out of the
staging directory.
- Request API conversion. Remove of the dual pipeline and associate buffers
as well as formats and the binary used to a request. Remove the
opportunistic buffer management. (Sakari)
- Using ENABLED and IMMUTABLE link flags for the links where those are
relevant. (Sakari)
- Prefix imgu for all public APIs, i.e. change ipu3_v4l2_register() to
imgu_v4l2_register(). (Sakari)
- Use V4L2_CTRL_TYPE_MENU for dual-pipe mode control. (Sakari)
- IPU3 driver documentation (Laurent)
Add diagram in driver rst to describe output capability.
Comments on configuring v4l2 subdevs for CIO2 and ImgU.
- uAPI documentation:
Further clarification on some ambiguities such as data type conversion of
IEFD CU inputs. (Sakari)
Move acronyms to doc-rst file. (Mauro)
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2018 Intel Corporation */
#ifndef __IPU3_H
#define __IPU3_H
#include <linux/iova.h>
#include <linux/pci.h>
#include <media/v4l2-device.h>
#include <media/videobuf2-dma-sg.h>
#include "ipu3-css.h"
#define IMGU_NAME "ipu3-imgu"
/*
* The semantics of the driver is that whenever there is a buffer available in
* master queue, the driver queues a buffer also to all other active nodes.
* If user space hasn't provided a buffer to all other video nodes first,
* the driver gets an internal dummy buffer and queues it.
*/
#define IMGU_QUEUE_MASTER IPU3_CSS_QUEUE_IN
#define IMGU_QUEUE_FIRST_INPUT IPU3_CSS_QUEUE_OUT
#define IMGU_MAX_QUEUE_DEPTH (2 + 2)
#define IMGU_NODE_IN 0 /* Input RAW image */
#define IMGU_NODE_PARAMS 1 /* Input parameters */
#define IMGU_NODE_OUT 2 /* Main output for still or video */
#define IMGU_NODE_VF 3 /* Preview */
#define IMGU_NODE_PV 4 /* Postview for still capture */
#define IMGU_NODE_STAT_3A 5 /* 3A statistics */
#define IMGU_NODE_NUM 6
#define file_to_intel_ipu3_node(__file) \
container_of(video_devdata(__file), struct imgu_video_device, vdev)
#define IPU3_INPUT_MIN_WIDTH 0U
#define IPU3_INPUT_MIN_HEIGHT 0U
#define IPU3_INPUT_MAX_WIDTH 5120U
#define IPU3_INPUT_MAX_HEIGHT 38404U
#define IPU3_OUTPUT_MIN_WIDTH 2U
#define IPU3_OUTPUT_MIN_HEIGHT 2U
#define IPU3_OUTPUT_MAX_WIDTH 4480U
#define IPU3_OUTPUT_MAX_HEIGHT 34004U
struct ipu3_vb2_buffer {
/* Public fields */
struct vb2_v4l2_buffer vbb; /* Must be the first field */
/* Private fields */
struct list_head list;
};
struct imgu_buffer {
struct ipu3_vb2_buffer vid_buf; /* Must be the first field */
struct ipu3_css_buffer css_buf;
struct ipu3_css_map map;
};
struct imgu_node_mapping {
unsigned int css_queue;
const char *name;
};
/**
* struct imgu_video_device
* each node registers as video device and maintains its
* own vb2_queue.
*/
struct imgu_video_device {
const char *name;
bool output;
bool immutable; /* Can not be enabled/disabled */
bool enabled;
struct v4l2_format vdev_fmt; /* Currently set format */
/* Private fields */
struct video_device vdev;
struct media_pad vdev_pad;
struct v4l2_mbus_framefmt pad_fmt;
struct vb2_queue vbq;
struct list_head buffers;
/* Protect vb2_queue and vdev structs*/
struct mutex lock;
atomic_t sequence;
};
/*
* imgu_device -- ImgU (Imaging Unit) driver
*/
struct imgu_device {
struct pci_dev *pci_dev;
void __iomem *base;
/* Internally enabled queues */
struct {
struct ipu3_css_map dmap;
struct ipu3_css_buffer dummybufs[IMGU_MAX_QUEUE_DEPTH];
} queues[IPU3_CSS_QUEUES];
struct imgu_video_device nodes[IMGU_NODE_NUM];
bool queue_enabled[IMGU_NODE_NUM];
/* Public fields, fill before registering */
unsigned int buf_struct_size;
bool streaming; /* Public read only */
struct v4l2_ctrl_handler *ctrl_handler;
/* Private fields */
struct v4l2_device v4l2_dev;
struct media_device media_dev;
struct media_pipeline pipeline;
struct v4l2_subdev subdev;
struct media_pad subdev_pads[IMGU_NODE_NUM];
struct v4l2_file_operations v4l2_file_ops;
/* MMU driver for css */
struct ipu3_mmu_info *mmu;
struct iova_domain iova_domain;
/* css - Camera Sub-System */
struct ipu3_css css;
/*
* Coarse-grained lock to protect
* vid_buf.list and css->queue
*/
struct mutex lock;
/* Forbit streaming and buffer queuing during system suspend. */
atomic_t qbuf_barrier;
struct {
struct v4l2_rect eff; /* effective resolution */
struct v4l2_rect bds; /* bayer-domain scaled resolution*/
struct v4l2_rect gdc; /* gdc output resolution */
} rect;
/* Indicate if system suspend take place while imgu is streaming. */
bool suspend_in_stream;
/* Used to wait for FW buffer queue drain. */
wait_queue_head_t buf_drain_wq;
};
unsigned int imgu_node_to_queue(unsigned int node);
unsigned int imgu_map_node(struct imgu_device *imgu, unsigned int css_queue);
int imgu_queue_buffers(struct imgu_device *imgu, bool initial);
int imgu_v4l2_register(struct imgu_device *dev);
int imgu_v4l2_unregister(struct imgu_device *dev);
void imgu_v4l2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
int imgu_s_stream(struct imgu_device *imgu, int enable);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment