media: camss: Add support for 10-bit grayscale formats
authorTodor Tomov <todor.tomov@linaro.org>
Wed, 25 Jul 2018 16:38:41 +0000 (12:38 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 2 Aug 2018 12:46:41 +0000 (08:46 -0400)
Add support for 10-bit packed V4L2_PIX_FMT_Y10P (on 8x16 and 8x96)
and unpacked V4L2_PIX_FMT_Y10 (on 8x96 only) pixel formats.

Signed-off-by: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/qcom/camss/camss-csid.c
drivers/media/platform/qcom/camss/camss-csiphy.c
drivers/media/platform/qcom/camss/camss-ispif.c
drivers/media/platform/qcom/camss/camss-vfe.c
drivers/media/platform/qcom/camss/camss-video.c

index 472884d..6e141af 100644 (file)
@@ -193,7 +193,14 @@ static const struct csid_format csid_formats_8x16[] = {
                DECODE_FORMAT_UNCOMPRESSED_12_BIT,
                12,
                1,
-       }
+       },
+       {
+               MEDIA_BUS_FMT_Y10_1X10,
+               DATA_TYPE_RAW_10BIT,
+               DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+               10,
+               1,
+       },
 };
 
 static const struct csid_format csid_formats_8x96[] = {
@@ -336,7 +343,14 @@ static const struct csid_format csid_formats_8x96[] = {
                DECODE_FORMAT_UNCOMPRESSED_14_BIT,
                14,
                1,
-       }
+       },
+       {
+               MEDIA_BUS_FMT_Y10_1X10,
+               DATA_TYPE_RAW_10BIT,
+               DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+               10,
+               1,
+       },
 };
 
 static u32 csid_find_code(u32 *code, unsigned int n_code,
@@ -379,6 +393,16 @@ static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
                        return csid_find_code(src_code, ARRAY_SIZE(src_code),
                                              index, src_req_code);
                }
+               case MEDIA_BUS_FMT_Y10_1X10:
+               {
+                       u32 src_code[] = {
+                               MEDIA_BUS_FMT_Y10_1X10,
+                               MEDIA_BUS_FMT_Y10_2X8_PADHI_LE,
+                       };
+
+                       return csid_find_code(src_code, ARRAY_SIZE(src_code),
+                                             index, src_req_code);
+               }
                default:
                        if (index > 0)
                                return 0;
@@ -689,15 +713,21 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
                val |= CAMSS_CSID_CID_n_CFG_RDI_EN;
                val |= df << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT;
                val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP;
-               if (csid->camss->version == CAMSS_8x96 &&
-                       csid->fmt[MSM_CSID_PAD_SINK].code ==
-                                       MEDIA_BUS_FMT_SBGGR10_1X10 &&
-                       csid->fmt[MSM_CSID_PAD_SRC].code ==
-                                       MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) {
-                       val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING;
-                       val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16;
-                       val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB;
+
+               if (csid->camss->version == CAMSS_8x96) {
+                       u32 sink_code = csid->fmt[MSM_CSID_PAD_SINK].code;
+                       u32 src_code = csid->fmt[MSM_CSID_PAD_SRC].code;
+
+                       if ((sink_code == MEDIA_BUS_FMT_SBGGR10_1X10 &&
+                            src_code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE) ||
+                           (sink_code == MEDIA_BUS_FMT_Y10_1X10 &&
+                            src_code == MEDIA_BUS_FMT_Y10_2X8_PADHI_LE)) {
+                               val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING;
+                               val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16;
+                               val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB;
+                       }
                }
+
                writel_relaxed(val, csid->base +
                               CAMSS_CSID_CID_n_CFG(ver, cid));
 
index cae3e8b..4559f3b 100644 (file)
@@ -45,6 +45,7 @@ static const struct csiphy_format csiphy_formats_8x16[] = {
        { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
        { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
        { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
+       { MEDIA_BUS_FMT_Y10_1X10, 10 },
 };
 
 static const struct csiphy_format csiphy_formats_8x96[] = {
@@ -68,6 +69,7 @@ static const struct csiphy_format csiphy_formats_8x96[] = {
        { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
        { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
        { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
+       { MEDIA_BUS_FMT_Y10_1X10, 10 },
 };
 
 /*
index 3e2f341..7f26902 100644 (file)
@@ -120,6 +120,7 @@ static const u32 ispif_formats_8x16[] = {
        MEDIA_BUS_FMT_SGBRG12_1X12,
        MEDIA_BUS_FMT_SGRBG12_1X12,
        MEDIA_BUS_FMT_SRGGB12_1X12,
+       MEDIA_BUS_FMT_Y10_1X10,
 };
 
 static const u32 ispif_formats_8x96[] = {
@@ -144,6 +145,8 @@ static const u32 ispif_formats_8x96[] = {
        MEDIA_BUS_FMT_SGBRG14_1X14,
        MEDIA_BUS_FMT_SGRBG14_1X14,
        MEDIA_BUS_FMT_SRGGB14_1X14,
+       MEDIA_BUS_FMT_Y10_1X10,
+       MEDIA_BUS_FMT_Y10_2X8_PADHI_LE,
 };
 
 /*
@@ -692,7 +695,8 @@ static void ispif_config_pack(struct ispif_device *ispif, u32 code,
 {
        u32 addr, val;
 
-       if (code != MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE)
+       if (code != MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE &&
+           code != MEDIA_BUS_FMT_Y10_2X8_PADHI_LE)
                return;
 
        switch (intf) {
index 9675309..ed6a557 100644 (file)
@@ -67,6 +67,7 @@ static const struct vfe_format formats_rdi_8x16[] = {
        { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
        { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
        { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
+       { MEDIA_BUS_FMT_Y10_1X10, 10 },
 };
 
 static const struct vfe_format formats_pix_8x16[] = {
@@ -98,6 +99,8 @@ static const struct vfe_format formats_rdi_8x96[] = {
        { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
        { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
        { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
+       { MEDIA_BUS_FMT_Y10_1X10, 10 },
+       { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
 };
 
 static const struct vfe_format formats_pix_8x96[] = {
index 2e19bc8..c9bb0d0 100644 (file)
@@ -74,6 +74,8 @@ static const struct camss_format_info formats_rdi_8x16[] = {
          { { 1, 1 } }, { { 1, 1 } }, { 12 } },
        { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
          { { 1, 1 } }, { { 1, 1 } }, { 12 } },
+       { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
+         { { 1, 1 } }, { { 1, 1 } }, { 10 } },
 };
 
 static const struct camss_format_info formats_rdi_8x96[] = {
@@ -119,6 +121,10 @@ static const struct camss_format_info formats_rdi_8x96[] = {
          { { 1, 1 } }, { { 1, 1 } }, { 14 } },
        { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
          { { 1, 1 } }, { { 1, 1 } }, { 14 } },
+       { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
+         { { 1, 1 } }, { { 1, 1 } }, { 10 } },
+       { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
+         { { 1, 1 } }, { { 1, 1 } }, { 16 } },
 };
 
 static const struct camss_format_info formats_pix_8x16[] = {