/* * flags on the 'direction' field in struct rkisp1_mbus_info' that indicate * on which pad the media bus format is supported
*/ #define RKISP1_ISP_SD_SRC BIT(0) #define RKISP1_ISP_SD_SINK BIT(1)
/* * Minimum values for the width and height of entities. The maximum values are * model-specific and stored in the rkisp1_info structure.
*/ #define RKISP1_ISP_MIN_WIDTH 32 #define RKISP1_ISP_MIN_HEIGHT 32
/* enum for the isp pads */ enum rkisp1_isp_pad {
RKISP1_ISP_PAD_SINK_VIDEO,
RKISP1_ISP_PAD_SINK_PARAMS,
RKISP1_ISP_PAD_SOURCE_VIDEO,
RKISP1_ISP_PAD_SOURCE_STATS,
RKISP1_ISP_PAD_MAX
};
/* * enum rkisp1_feature - ISP features * * @RKISP1_FEATURE_MIPI_CSI2: The ISP has an internal MIPI CSI-2 receiver * @RKISP1_FEATURE_MAIN_STRIDE: The ISP supports configurable stride on the main path * @RKISP1_FEATURE_SELF_PATH: The ISP has a self path * @RKISP1_FEATURE_DUAL_CROP: The ISP has the dual crop block at the resizer input * @RKISP1_FEATURE_DMA_34BIT: The ISP uses 34-bit DMA addresses * @RKISP1_FEATURE_BLS: The ISP has a dedicated BLS block * @RKISP1_FEATURE_COMPAND: The ISP has a companding block * * The ISP features are stored in a bitmask in &rkisp1_info.features and allow * the driver to implement support for features present in some ISP versions * only.
*/ enum rkisp1_feature {
RKISP1_FEATURE_MIPI_CSI2 = BIT(0),
RKISP1_FEATURE_MAIN_STRIDE = BIT(1),
RKISP1_FEATURE_SELF_PATH = BIT(2),
RKISP1_FEATURE_DUAL_CROP = BIT(3),
RKISP1_FEATURE_DMA_34BIT = BIT(4),
RKISP1_FEATURE_BLS = BIT(5),
RKISP1_FEATURE_COMPAND = BIT(6),
};
/* * struct rkisp1_info - Model-specific ISP Information * * @clks: array of ISP clock names * @clk_size: number of entries in the @clks array * @isrs: array of ISP interrupt descriptors * @isr_size: number of entries in the @isrs array * @isp_ver: ISP version * @features: bitmask of rkisp1_feature features implemented by the ISP * @max_width: maximum input frame width * @max_height: maximum input frame height * * This structure contains information about the ISP specific to a particular * ISP model, version, or integration in a particular SoC.
*/ struct rkisp1_info { constchar * const *clks; unsignedint clk_size; conststruct rkisp1_isr_data *isrs; unsignedint isr_size; enum rkisp1_cif_isp_version isp_ver; unsignedint features; unsignedint max_width; unsignedint max_height;
};
/* * struct rkisp1_sensor_async - A container for the v4l2_async_subdev to add to the notifier * of the v4l2-async API * * @asd: async_subdev variable for the sensor * @index: index of the sensor (counting sensor found in DT) * @source_ep: fwnode for the sensor source endpoint * @lanes: number of lanes * @mbus_type: type of bus (currently only CSI2 is supported) * @mbus_flags: media bus (V4L2_MBUS_*) flags * @sd: a pointer to v4l2_subdev struct of the sensor * @pixel_rate_ctrl: pixel rate of the sensor, used to initialize the phy * @port: port number (0: MIPI, 1: Parallel)
*/ struct rkisp1_sensor_async { struct v4l2_async_connection asd; unsignedint index; struct fwnode_handle *source_ep; unsignedint lanes; enum v4l2_mbus_type mbus_type; unsignedint mbus_flags; struct v4l2_subdev *sd; struct v4l2_ctrl *pixel_rate_ctrl; unsignedint port;
};
/* * struct rkisp1_csi - CSI receiver subdev * * @rkisp1: pointer to the rkisp1 device * @dphy: a pointer to the phy * @is_dphy_errctrl_disabled: if dphy errctrl is disabled (avoid endless interrupt) * @sd: v4l2_subdev variable * @pads: media pads * @source: source in-use, set when starting streaming
*/ struct rkisp1_csi { struct rkisp1_device *rkisp1; struct phy *dphy; bool is_dphy_errctrl_disabled; struct v4l2_subdev sd; struct media_pad pads[RKISP1_CSI_PAD_NUM]; struct v4l2_subdev *source;
};
/* * struct rkisp1_isp - ISP subdev entity * * @sd: v4l2_subdev variable * @rkisp1: pointer to rkisp1_device * @pads: media pads * @sink_fmt: input format * @frame_sequence: used to synchronize frame_id between video devices.
*/ struct rkisp1_isp { struct v4l2_subdev sd; struct rkisp1_device *rkisp1; struct media_pad pads[RKISP1_ISP_PAD_MAX]; conststruct rkisp1_mbus_info *sink_fmt;
__u32 frame_sequence;
};
/* * struct rkisp1_vdev_node - Container for the video nodes: params, stats, mainpath, selfpath * * @buf_queue: queue of buffers * @vlock: lock of the video node * @vdev: video node * @pad: media pad
*/ struct rkisp1_vdev_node { struct vb2_queue buf_queue; struct mutex vlock; /* ioctl serialization mutex */ struct video_device vdev; struct media_pad pad;
};
/* * struct rkisp1_buffer - A container for the vb2 buffers used by the video devices: * stats, mainpath, selfpath * * @vb: vb2 buffer * @queue: entry of the buffer in the queue * @buff_addr: dma addresses of each plane, used only by the capture devices: selfpath, mainpath
*/ struct rkisp1_buffer { struct vb2_v4l2_buffer vb; struct list_head queue;
dma_addr_t buff_addr[VIDEO_MAX_PLANES];
};
/* * struct rkisp1_params_buffer - A container for the vb2 buffers used by the * params video device * * @vb: vb2 buffer * @queue: entry of the buffer in the queue * @cfg: scratch buffer used for caching the ISP configuration parameters
*/ struct rkisp1_params_buffer { struct vb2_v4l2_buffer vb; struct list_head queue; void *cfg;
};
/* * struct rkisp1_dummy_buffer - A buffer to write the next frame to in case * there are no vb2 buffers available. * * @vaddr: return value of call to dma_alloc_attrs. * @dma_addr: dma address of the buffer. * @size: size of the buffer.
*/ struct rkisp1_dummy_buffer { void *vaddr;
dma_addr_t dma_addr;
u32 size;
};
struct rkisp1_device;
/* * struct rkisp1_capture - ISP capture video device * * @vnode: video node * @rkisp1: pointer to rkisp1_device * @id: id of the capture, one of RKISP1_SELFPATH, RKISP1_MAINPATH * @ops: list of callbacks to configure the capture device. * @config: a pointer to the list of registers to configure the capture format. * @is_streaming: device is streaming * @is_stopping: stop_streaming callback was called and the device is in the process of * stopping the streaming. * @done: when stop_streaming callback is called, the device waits for the next irq * handler to stop the streaming by waiting on the 'done' wait queue. * If the irq handler is not called, the stream is stopped by the callback * after timeout. * @stride: the line stride for the first plane, in pixel units * @buf.lock: lock to protect buf.queue * @buf.queue: queued buffer list * @buf.dummy: dummy space to store dropped data * * rkisp1 uses shadow registers, so it needs two buffers at a time * @buf.curr: the buffer used for current frame * @buf.next: the buffer used for next frame * @pix.cfg: pixel configuration * @pix.info: a pointer to the v4l2_format_info of the pixel format * @pix.fmt: buffer format
*/ struct rkisp1_capture { struct rkisp1_vdev_node vnode; struct rkisp1_device *rkisp1; enum rkisp1_stream_id id; conststruct rkisp1_capture_ops *ops; conststruct rkisp1_capture_config *config; bool is_streaming; bool is_stopping;
wait_queue_head_t done; unsignedint stride; struct { /* protects queue, curr and next */
spinlock_t lock; struct list_head queue; struct rkisp1_dummy_buffer dummy; struct rkisp1_buffer *curr; struct rkisp1_buffer *next;
} buf; struct { conststruct rkisp1_capture_fmt_cfg *cfg; conststruct v4l2_format_info *info; struct v4l2_pix_format_mplane fmt;
} pix;
};
/* * struct rkisp1_params - ISP input parameters device * * @vnode: video node * @rkisp1: pointer to the rkisp1 device * @ops: pointer to the variant-specific operations * @config_lock: locks the buffer list 'params' * @params: queue of rkisp1_buffer * @metafmt the currently enabled metadata format * @quantization: the quantization configured on the isp's src pad * @ycbcr_encoding the YCbCr encoding * @raw_type: the bayer pattern on the isp video sink pad * @enabled_blocks: bitmask of enabled ISP blocks
*/ struct rkisp1_params { struct rkisp1_vdev_node vnode; struct rkisp1_device *rkisp1; conststruct rkisp1_params_ops *ops;
spinlock_t config_lock; /* locks the buffers list 'params' */ struct list_head params;
/* * struct rkisp1_resizer - Resizer subdev * * @sd: v4l2_subdev variable * @regs_base: base register address offset * @id: id of the resizer, one of RKISP1_SELFPATH, RKISP1_MAINPATH * @rkisp1: pointer to the rkisp1 device * @pads: media pads * @config: the set of registers to configure the resizer
*/ struct rkisp1_resizer { struct v4l2_subdev sd;
u32 regs_base; enum rkisp1_stream_id id; struct rkisp1_device *rkisp1; struct media_pad pads[RKISP1_RSZ_PAD_MAX]; conststruct rkisp1_rsz_config *config;
};
/* * struct rkisp1_debug - Values to be exposed on debugfs. * The parameters are counters of the number of times the * event occurred since the driver was loaded. * * @data_loss: loss of data occurred within a line, processing failure * @outform_size_error: size error is generated in outmux submodule * @img_stabilization_size_error: size error is generated in image stabilization submodule * @inform_size_err: size error is generated in inform submodule * @mipi_error: mipi error occurred * @stats_error: writing to the 'Interrupt clear register' did not clear * it in the register 'Masked interrupt status' * @stop_timeout: upon stream stop, the capture waits 1 second for the isr to stop * the stream. This param is incremented in case of timeout. * @frame_drop: a frame was ready but the buffer queue was empty so the frame * was not sent to userspace
*/ struct rkisp1_debug { struct dentry *debugfs_dir; unsignedlong data_loss; unsignedlong outform_size_error; unsignedlong img_stabilization_size_error; unsignedlong inform_size_error; unsignedlong irq_delay; unsignedlong mipi_error; unsignedlong stats_error; unsignedlong stop_timeout[2]; unsignedlong frame_drop[2]; unsignedlong complete_frames;
};
/* * struct rkisp1_device - ISP platform device * * @base_addr: base register address * @dev: a pointer to the struct device * @clk_size: number of clocks * @clks: array of clocks * @gasket: the gasket - i.MX8MP only * @gasket_id: the gasket ID (0 or 1) - i.MX8MP only * @v4l2_dev: v4l2_device variable * @media_dev: media_device variable * @notifier: a notifier to register on the v4l2-async API to be notified on the sensor * @source: source subdev in-use, set when starting streaming * @csi: internal CSI-2 receiver * @isp: ISP sub-device * @resizer_devs: resizer sub-devices * @capture_devs: capture devices * @stats: ISP statistics metadata capture device * @params: ISP parameters metadata output device * @pipe: media pipeline * @stream_lock: serializes {start/stop}_streaming callbacks between the capture devices. * @debug: debug params to be exposed on debugfs * @info: version-specific ISP information * @irqs: IRQ line numbers * @irqs_enabled: the hardware is enabled and can cause interrupts
*/ struct rkisp1_device { void __iomem *base_addr; struct device *dev; unsignedint clk_size; struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK]; struct regmap *gasket; unsignedint gasket_id; struct v4l2_device v4l2_dev; struct media_device media_dev; struct v4l2_async_notifier notifier; struct v4l2_subdev *source; struct rkisp1_csi csi; struct rkisp1_isp isp; struct rkisp1_resizer resizer_devs[2]; struct rkisp1_capture capture_devs[2]; struct rkisp1_stats stats; struct rkisp1_params params; struct media_pipeline pipe; struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */ struct rkisp1_debug debug; conststruct rkisp1_info *info; int irqs[RKISP1_NUM_IRQS]; bool irqs_enabled;
};
/* * struct rkisp1_mbus_info - ISP media bus info, Translates media bus code to hardware * format values * * @mbus_code: media bus code * @pixel_enc: pixel encoding * @mipi_dt: mipi data type * @yuv_seq: the order of the Y, Cb, Cr values * @bus_width: bus width * @bayer_pat: bayer pattern * @direction: a bitmask of the flags indicating on which pad the format is supported on
*/ struct rkisp1_mbus_info {
u32 mbus_code; enum v4l2_pixel_encoding pixel_enc;
u32 mipi_dt;
u32 yuv_seq;
u8 bus_width; enum rkisp1_fmt_raw_pat_type bayer_pat; unsignedint direction;
};
/* * rkisp1_cap_enum_mbus_codes - A helper function that return the i'th supported mbus code * of the capture entity. This is used to enumerate the supported * mbus codes on the source pad of the resizer. * * @cap: the capture entity * @code: the mbus code, the function reads the code->index and fills the code->code
*/ int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap, struct v4l2_subdev_mbus_code_enum *code);
/* * rkisp1_mbus_info_get_by_index - Retrieve the ith supported mbus info * * @index: index of the mbus info to fetch
*/ conststruct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsignedint index);
/* * rkisp1_path_count - Return the number of paths supported by the device * * Some devices only have a main path, while other device have both a main path * and a self path. This function returns the number of paths that this device * has, based on the feature flags. It should be used insted of checking * ARRAY_SIZE of capture_devs/resizer_devs.
*/ staticinlineunsignedint rkisp1_path_count(struct rkisp1_device *rkisp1)
{ return rkisp1_has_feature(rkisp1, SELF_PATH) ? 2 : 1;
}
/* * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle. * * @crop: rectangle to adjust. * @bounds: rectangle used as bounds.
*/ void rkisp1_sd_adjust_crop_rect(struct v4l2_rect *crop, conststruct v4l2_rect *bounds);
/* * rkisp1_sd_adjust_crop - adjust a rectangle to fit into media bus format * * @crop: rectangle to adjust. * @bounds: media bus format used as bounds.
*/ void rkisp1_sd_adjust_crop(struct v4l2_rect *crop, conststruct v4l2_mbus_framefmt *bounds);
/* * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code * * @mbus_code: the media bus code
*/ conststruct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code);
/* * rkisp1_params_pre_configure - Configure the params before stream start * * @params: pointer to rkisp1_params * @bayer_pat: the bayer pattern on the isp video sink pad * @quantization: the quantization configured on the isp's src pad * @ycbcr_encoding: the ycbcr_encoding configured on the isp's src pad * * This function is called by the ISP entity just before the ISP gets started. * It applies the initial ISP parameters from the first params buffer, but * skips LSC as it needs to be configured after the ISP is started.
*/ void rkisp1_params_pre_configure(struct rkisp1_params *params, enum rkisp1_fmt_raw_pat_type bayer_pat, enum v4l2_quantization quantization, enum v4l2_ycbcr_encoding ycbcr_encoding);
/* * rkisp1_params_post_configure - Configure the params after stream start * * @params: pointer to rkisp1_params * * This function is called by the ISP entity just after the ISP gets started. * It applies the initial ISP LSC parameters from the first params buffer.
*/ void rkisp1_params_post_configure(struct rkisp1_params *params);
/* rkisp1_params_disable - disable all parameters. * This function is called by the isp entity upon stream start * when capturing bayer format. * * @params: pointer to rkisp1_params.
*/ void rkisp1_params_disable(struct rkisp1_params *params);
/* register/unregisters functions of the entities */ int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1); void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1);
int rkisp1_isp_register(struct rkisp1_device *rkisp1); void rkisp1_isp_unregister(struct rkisp1_device *rkisp1);
int rkisp1_resizer_devs_register(struct rkisp1_device *rkisp1); void rkisp1_resizer_devs_unregister(struct rkisp1_device *rkisp1);
int rkisp1_stats_register(struct rkisp1_device *rkisp1); void rkisp1_stats_unregister(struct rkisp1_device *rkisp1);
int rkisp1_params_register(struct rkisp1_device *rkisp1); void rkisp1_params_unregister(struct rkisp1_device *rkisp1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.