]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] s5p-fimc: Derive camera bus width from mediabus pixelcode
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Mon, 27 Dec 2010 18:02:16 +0000 (15:02 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 21 Mar 2011 23:31:38 +0000 (20:31 -0300)
Remove bus_width from s5p_fimc_isp_info data structure.
Determine camera data bus width based on mediabus pixel format.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/s5p-fimc/fimc-reg.c
include/media/s5p_fimc.h

index ae33bc1c7bd4d9faf8007987c4a00c67fe0a8ef8..63660119ef7f016e7e8312aa924caa45ff233ddd 100644 (file)
@@ -561,37 +561,42 @@ int fimc_hw_set_camera_source(struct fimc_dev *fimc,
 {
        struct fimc_frame *f = &fimc->vid_cap.ctx->s_frame;
        u32 cfg = 0;
+       u32 bus_width;
+       int i;
+
+       static const struct {
+               u32 pixelcode;
+               u32 cisrcfmt;
+               u16 bus_width;
+       } pix_desc[] = {
+               { V4L2_MBUS_FMT_YUYV8_2X8, S5P_CISRCFMT_ORDER422_YCBYCR, 8 },
+               { V4L2_MBUS_FMT_YVYU8_2X8, S5P_CISRCFMT_ORDER422_YCRYCB, 8 },
+               { V4L2_MBUS_FMT_VYUY8_2X8, S5P_CISRCFMT_ORDER422_CRYCBY, 8 },
+               { V4L2_MBUS_FMT_UYVY8_2X8, S5P_CISRCFMT_ORDER422_CBYCRY, 8 },
+               /* TODO: Add pixel codes for 16-bit bus width */
+       };
 
        if (cam->bus_type == FIMC_ITU_601 || cam->bus_type == FIMC_ITU_656) {
+               for (i = 0; i < ARRAY_SIZE(pix_desc); i++) {
+                       if (fimc->vid_cap.fmt.code == pix_desc[i].pixelcode) {
+                               cfg = pix_desc[i].cisrcfmt;
+                               bus_width = pix_desc[i].bus_width;
+                               break;
+                       }
+               }
 
-               switch (fimc->vid_cap.fmt.code) {
-               case V4L2_MBUS_FMT_YUYV8_2X8:
-                       cfg = S5P_CISRCFMT_ORDER422_YCBYCR;
-                       break;
-               case V4L2_MBUS_FMT_YVYU8_2X8:
-                       cfg = S5P_CISRCFMT_ORDER422_YCRYCB;
-                       break;
-               case V4L2_MBUS_FMT_VYUY8_2X8:
-                       cfg = S5P_CISRCFMT_ORDER422_CRYCBY;
-                       break;
-               case V4L2_MBUS_FMT_UYVY8_2X8:
-                       cfg = S5P_CISRCFMT_ORDER422_CBYCRY;
-                       break;
-               default:
-                       err("camera image format not supported: %d",
-                           fimc->vid_cap.fmt.code);
+               if (i == ARRAY_SIZE(pix_desc)) {
+                       v4l2_err(&fimc->vid_cap.v4l2_dev,
+                                "Camera color format not supported: %d\n",
+                                fimc->vid_cap.fmt.code);
                        return -EINVAL;
                }
 
                if (cam->bus_type == FIMC_ITU_601) {
-                       if (cam->bus_width == 8) {
+                       if (bus_width == 8)
                                cfg |= S5P_CISRCFMT_ITU601_8BIT;
-                       } else if (cam->bus_width == 16) {
+                       else if (bus_width == 16)
                                cfg |= S5P_CISRCFMT_ITU601_16BIT;
-                       } else {
-                               err("invalid bus width: %d", cam->bus_width);
-                               return -EINVAL;
-                       }
                } /* else defaults to ITU-R BT.656 8-bit */
        }
 
index eb8793fd150eda725deccc7bdc2c6a1a8c189eed..d30b9dee0f3b5731b304bb4f5db925176eccf8e5 100644 (file)
@@ -34,7 +34,6 @@ struct i2c_board_info;
  * @bus_type: determines bus type, MIPI, ITU-R BT.601 etc.
  * @i2c_bus_num: i2c control bus id the sensor is attached to
  * @mux_id: FIMC camera interface multiplexer index (separate for MIPI and ITU)
- * @bus_width: camera data bus width in bits
  * @flags: flags defining bus signals polarity inversion (High by default)
  */
 struct s5p_fimc_isp_info {
@@ -42,7 +41,6 @@ struct s5p_fimc_isp_info {
        enum cam_bus_type bus_type;
        u16 i2c_bus_num;
        u16 mux_id;
-       u16 bus_width;
        u16 flags;
 };