Merge tag 'media/v6.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[linux-2.6-microblaze.git] / drivers / media / platform / rockchip / rkisp1 / rkisp1-common.h
index b757f75..26573f6 100644 (file)
@@ -24,6 +24,7 @@
 #include "rkisp1-regs.h"
 
 struct dentry;
+struct regmap;
 
 /*
  * flags on the 'direction' field in struct rkisp1_mbus_info' that indicate
@@ -110,6 +111,10 @@ enum rkisp1_isp_pad {
  * 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
  *
  * 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
@@ -117,8 +122,15 @@ enum rkisp1_isp_pad {
  */
 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),
 };
 
+#define rkisp1_has_feature(rkisp1, feature) \
+       ((rkisp1)->info->features & RKISP1_FEATURE_##feature)
+
 /*
  * struct rkisp1_info - Model-specific ISP Information
  *
@@ -229,7 +241,7 @@ struct rkisp1_vdev_node {
 struct rkisp1_buffer {
        struct vb2_v4l2_buffer vb;
        struct list_head queue;
-       u32 buff_addr[VIDEO_MAX_PLANES];
+       dma_addr_t buff_addr[VIDEO_MAX_PLANES];
 };
 
 /*
@@ -263,7 +275,7 @@ struct rkisp1_device;
  *               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.
- * @sp_y_stride:  the selfpath allows to configure a y stride that is longer than the image width.
+ * @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
@@ -284,7 +296,7 @@ struct rkisp1_capture {
        bool is_streaming;
        bool is_stopping;
        wait_queue_head_t done;
-       unsigned int sp_y_stride;
+       unsigned int stride;
        struct {
                /* protects queue, curr and next */
                spinlock_t lock;
@@ -435,6 +447,8 @@ struct rkisp1_debug {
  * @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
@@ -457,6 +471,8 @@ struct rkisp1_device {
        struct device *dev;
        unsigned int clk_size;
        struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK];
+       struct regmap *gasket;
+       unsigned int gasket_id;
        struct v4l2_device v4l2_dev;
        struct media_device media_dev;
        struct v4l2_async_notifier notifier;
@@ -526,6 +542,19 @@ int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap,
  */
 const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int 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.
+ */
+static inline unsigned int 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.
  *