diff mbox series

media: staging: rkisp1: cap: remove field fmt_type from struct rkisp1_capture_fmt_cfg

Message ID 20200328084915.21398-1-dafna.hirschfeld@collabora.com (mailing list archive)
State New, archived
Headers show
Series media: staging: rkisp1: cap: remove field fmt_type from struct rkisp1_capture_fmt_cfg | expand

Commit Message

Dafna Hirschfeld March 28, 2020, 8:49 a.m. UTC
The pixel encoding can be retrieved from the cap->pix.info.
Therefore the field fmt_type can be removed from the
struct rkisp1_capture_fmt_cfg.

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/staging/media/rkisp1/rkisp1-capture.c | 62 +++++--------------
 1 file changed, 17 insertions(+), 45 deletions(-)

Comments

kernel test robot March 28, 2020, 11:35 a.m. UTC | #1
Hi Dafna,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on linuxtv-media/master v5.6-rc7 next-20200327]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Dafna-Hirschfeld/media-staging-rkisp1-cap-remove-field-fmt_type-from-struct-rkisp1_capture_fmt_cfg/20200328-171629
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git e681bb287f40e7a9dbcb04cef80fd87a2511ab86
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/staging/media/rkisp1/rkisp1-capture.c:107:4: error: 'const struct rkisp1_capture_fmt_cfg' has no member named 'fmt_type'
      .fmt_type = RKISP1_FMT_YUV,
       ^~~~~~~~
   drivers/staging/media/rkisp1/rkisp1-capture.c:112:4: error: 'const struct rkisp1_capture_fmt_cfg' has no member named 'fmt_type'
      .fmt_type = RKISP1_FMT_YUV,
       ^~~~~~~~
   drivers/staging/media/rkisp1/rkisp1-capture.c:218:4: error: 'const struct rkisp1_capture_fmt_cfg' has no member named 'fmt_type'
      .fmt_type = RKISP1_FMT_YUV,
       ^~~~~~~~
   drivers/staging/media/rkisp1/rkisp1-capture.c:224:4: error: 'const struct rkisp1_capture_fmt_cfg' has no member named 'fmt_type'
      .fmt_type = RKISP1_FMT_YUV,
       ^~~~~~~~

vim +107 drivers/staging/media/rkisp1/rkisp1-capture.c

0b24cb2fa2ad28 Dafna Hirschfeld 2020-03-28   98  
56e3b29f9f6b27 Helen Koike      2020-01-08   99  static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
56e3b29f9f6b27 Helen Koike      2020-01-08  100  	/* yuv422 */
56e3b29f9f6b27 Helen Koike      2020-01-08  101  	{
56e3b29f9f6b27 Helen Koike      2020-01-08  102  		.fourcc = V4L2_PIX_FMT_YUYV,
56e3b29f9f6b27 Helen Koike      2020-01-08  103  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  104  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
56e3b29f9f6b27 Helen Koike      2020-01-08  105  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  106  		.fourcc = V4L2_PIX_FMT_YVYU,
56e3b29f9f6b27 Helen Koike      2020-01-08 @107  		.fmt_type = RKISP1_FMT_YUV,
56e3b29f9f6b27 Helen Koike      2020-01-08  108  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  109  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
56e3b29f9f6b27 Helen Koike      2020-01-08  110  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  111  		.fourcc = V4L2_PIX_FMT_VYUY,
56e3b29f9f6b27 Helen Koike      2020-01-08  112  		.fmt_type = RKISP1_FMT_YUV,
56e3b29f9f6b27 Helen Koike      2020-01-08  113  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
56e3b29f9f6b27 Helen Koike      2020-01-08  114  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  115  		.fourcc = V4L2_PIX_FMT_YUV422P,
56e3b29f9f6b27 Helen Koike      2020-01-08  116  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  117  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  118  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  119  		.fourcc = V4L2_PIX_FMT_NV16,
56e3b29f9f6b27 Helen Koike      2020-01-08  120  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  121  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  122  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  123  		.fourcc = V4L2_PIX_FMT_NV61,
56e3b29f9f6b27 Helen Koike      2020-01-08  124  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  125  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  126  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  127  		.fourcc = V4L2_PIX_FMT_YVU422M,
56e3b29f9f6b27 Helen Koike      2020-01-08  128  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  129  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  130  	},
56e3b29f9f6b27 Helen Koike      2020-01-08  131  	/* yuv420 */
56e3b29f9f6b27 Helen Koike      2020-01-08  132  	{
56e3b29f9f6b27 Helen Koike      2020-01-08  133  		.fourcc = V4L2_PIX_FMT_NV21,
56e3b29f9f6b27 Helen Koike      2020-01-08  134  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  135  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  136  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  137  		.fourcc = V4L2_PIX_FMT_NV12,
56e3b29f9f6b27 Helen Koike      2020-01-08  138  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  139  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  140  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  141  		.fourcc = V4L2_PIX_FMT_NV21M,
56e3b29f9f6b27 Helen Koike      2020-01-08  142  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  143  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  144  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  145  		.fourcc = V4L2_PIX_FMT_NV12M,
56e3b29f9f6b27 Helen Koike      2020-01-08  146  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  147  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
56e3b29f9f6b27 Helen Koike      2020-01-08  148  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  149  		.fourcc = V4L2_PIX_FMT_YUV420,
56e3b29f9f6b27 Helen Koike      2020-01-08  150  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  151  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  152  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  153  		.fourcc = V4L2_PIX_FMT_YVU420,
56e3b29f9f6b27 Helen Koike      2020-01-08  154  		.uv_swap = 1,
56e3b29f9f6b27 Helen Koike      2020-01-08  155  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  156  	},
56e3b29f9f6b27 Helen Koike      2020-01-08  157  	/* yuv444 */
56e3b29f9f6b27 Helen Koike      2020-01-08  158  	{
56e3b29f9f6b27 Helen Koike      2020-01-08  159  		.fourcc = V4L2_PIX_FMT_YUV444M,
56e3b29f9f6b27 Helen Koike      2020-01-08  160  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  161  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  162  	},
56e3b29f9f6b27 Helen Koike      2020-01-08  163  	/* yuv400 */
56e3b29f9f6b27 Helen Koike      2020-01-08  164  	{
56e3b29f9f6b27 Helen Koike      2020-01-08  165  		.fourcc = V4L2_PIX_FMT_GREY,
56e3b29f9f6b27 Helen Koike      2020-01-08  166  		.uv_swap = 0,
56e3b29f9f6b27 Helen Koike      2020-01-08  167  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
56e3b29f9f6b27 Helen Koike      2020-01-08  168  	},
56e3b29f9f6b27 Helen Koike      2020-01-08  169  	/* raw */
56e3b29f9f6b27 Helen Koike      2020-01-08  170  	{
56e3b29f9f6b27 Helen Koike      2020-01-08  171  		.fourcc = V4L2_PIX_FMT_SRGGB8,
56e3b29f9f6b27 Helen Koike      2020-01-08  172  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  173  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  174  		.fourcc = V4L2_PIX_FMT_SGRBG8,
56e3b29f9f6b27 Helen Koike      2020-01-08  175  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  176  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  177  		.fourcc = V4L2_PIX_FMT_SGBRG8,
56e3b29f9f6b27 Helen Koike      2020-01-08  178  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  179  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  180  		.fourcc = V4L2_PIX_FMT_SBGGR8,
56e3b29f9f6b27 Helen Koike      2020-01-08  181  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
56e3b29f9f6b27 Helen Koike      2020-01-08  182  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  183  		.fourcc = V4L2_PIX_FMT_SRGGB10,
56e3b29f9f6b27 Helen Koike      2020-01-08  184  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  185  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  186  		.fourcc = V4L2_PIX_FMT_SGRBG10,
56e3b29f9f6b27 Helen Koike      2020-01-08  187  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  188  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  189  		.fourcc = V4L2_PIX_FMT_SGBRG10,
56e3b29f9f6b27 Helen Koike      2020-01-08  190  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  191  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  192  		.fourcc = V4L2_PIX_FMT_SBGGR10,
56e3b29f9f6b27 Helen Koike      2020-01-08  193  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  194  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  195  		.fourcc = V4L2_PIX_FMT_SRGGB12,
56e3b29f9f6b27 Helen Koike      2020-01-08  196  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  197  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  198  		.fourcc = V4L2_PIX_FMT_SGRBG12,
56e3b29f9f6b27 Helen Koike      2020-01-08  199  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  200  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  201  		.fourcc = V4L2_PIX_FMT_SGBRG12,
56e3b29f9f6b27 Helen Koike      2020-01-08  202  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  203  	}, {
56e3b29f9f6b27 Helen Koike      2020-01-08  204  		.fourcc = V4L2_PIX_FMT_SBGGR12,
56e3b29f9f6b27 Helen Koike      2020-01-08  205  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
56e3b29f9f6b27 Helen Koike      2020-01-08  206  	},
56e3b29f9f6b27 Helen Koike      2020-01-08  207  };
56e3b29f9f6b27 Helen Koike      2020-01-08  208  

:::::: The code at line 107 was first introduced by commit
:::::: 56e3b29f9f6b27a063df2a31f148782073cbe5e9 media: staging: rkisp1: add streaming paths

:::::: TO: Helen Koike <helen.koike@collabora.com>
:::::: CC: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Helen Mae Koike Fornazier March 30, 2020, 7:52 p.m. UTC | #2
Hi Dafna,

Thank you for the patch

On 3/28/20 5:49 AM, Dafna Hirschfeld wrote:
> The pixel encoding can be retrieved from the cap->pix.info.
> Therefore the field fmt_type can be removed from the
> struct rkisp1_capture_fmt_cfg.
> 
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> ---
>  drivers/staging/media/rkisp1/rkisp1-capture.c | 62 +++++--------------
>  1 file changed, 17 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
> index 24fe6a7888aa..01e1ff5943f1 100644
> --- a/drivers/staging/media/rkisp1/rkisp1-capture.c
> +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
> @@ -52,7 +52,6 @@ enum rkisp1_plane {
>   */
>  struct rkisp1_capture_fmt_cfg {
>  	u32 fourcc;
> -	u8 fmt_type;
>  	u8 uv_swap;
>  	u32 write_format;
>  	u32 output_format;
> @@ -83,11 +82,24 @@ struct rkisp1_capture_config {
>  	} mi;
>  };
>  
> +static enum rkisp1_fmt_pix_type
> +rkisp1_pixel_enc_to_fmt_pix(const struct v4l2_format_info *f)
> +{
> +	switch (f->pixel_enc) {
> +	case V4L2_PIXEL_ENC_RGB:
> +		return RKISP1_FMT_RGB;
> +	case V4L2_PIXEL_ENC_YUV:
> +		return RKISP1_FMT_YUV;
> +	case V4L2_PIXEL_ENC_BAYER:
> +		return RKISP1_FMT_BAYER;
> +	}
> +	return V4L2_PIXEL_ENC_UNKNOWN;
> +}

Can't we remove enum·rkisp1_fmt_pix_type completly? And use V4L2_PIXEL_ENC_* directly?

Regards,
Helen

> +
>  static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
>  	/* yuv422 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_YUYV,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
>  	}, {
> @@ -101,119 +113,95 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YUV422P,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV16,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV61,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YVU422M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	},
>  	/* yuv420 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_NV21,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV12,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV21M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV12M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YUV420,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YVU420,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	},
>  	/* yuv444 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_YUV444M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	},
>  	/* yuv400 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_GREY,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
>  	},
>  	/* raw */
>  	{
>  		.fourcc = V4L2_PIX_FMT_SRGGB8,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGRBG8,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGBRG8,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SBGGR8,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SRGGB10,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGRBG10,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGBRG10,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SBGGR10,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SRGGB12,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGRBG12,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SGBRG12,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_SBGGR12,
> -		.fmt_type = RKISP1_FMT_BAYER,
>  		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
>  	},
>  };
> @@ -222,7 +210,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  	/* yuv422 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_YUYV,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_INT,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
> @@ -240,25 +227,21 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YUV422P,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV16,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV61,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YVU422M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
> @@ -266,37 +249,31 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  	/* yuv420 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_NV21,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV12,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV21M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_NV12M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YUV420,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_YVU420,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 1,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
> @@ -304,7 +281,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  	/* yuv444 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_YUV444M,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV444,
> @@ -312,7 +288,6 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  	/* yuv400 */
>  	{
>  		.fourcc = V4L2_PIX_FMT_GREY,
> -		.fmt_type = RKISP1_FMT_YUV,
>  		.uv_swap = 0,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_INT,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV400,
> @@ -320,17 +295,14 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
>  	/* rgb */
>  	{
>  		.fourcc = V4L2_PIX_FMT_RGB24,
> -		.fmt_type = RKISP1_FMT_RGB,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB888,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_RGB565,
> -		.fmt_type = RKISP1_FMT_RGB,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB565,
>  	}, {
>  		.fourcc = V4L2_PIX_FMT_BGR666,
> -		.fmt_type = RKISP1_FMT_RGB,
>  		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
>  		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB666,
>  	},
> @@ -504,13 +476,12 @@ static void rkisp1_sp_disable(struct rkisp1_capture *cap)
>  
>  static void rkisp1_mp_enable(struct rkisp1_capture *cap)
>  {
> -	const struct rkisp1_capture_fmt_cfg *isp_fmt = cap->pix.cfg;
>  	u32 mi_ctrl;
>  
>  	rkisp1_mp_disable(cap);
>  
>  	mi_ctrl = rkisp1_read(cap->rkisp1, RKISP1_CIF_MI_CTRL);
> -	if (isp_fmt->fmt_type == RKISP1_FMT_BAYER)
> +	if (v4l2_is_format_bayer(cap->pix.info))
>  		mi_ctrl |= RKISP1_CIF_MI_CTRL_RAW_ENABLE;
>  	/* YUV */
>  	else
> @@ -1260,7 +1231,8 @@ static int rkisp1_capture_link_validate(struct media_link *link)
>  		return -EPIPE;
>  	}
>  
> -	if (cap->pix.cfg->fmt_type != isp->src_fmt->fmt_type) {
> +	if (rkisp1_pixel_enc_to_fmt_pix(cap->pix.info) !=
> +	    isp->src_fmt->fmt_type) {
>  		dev_err(cap->rkisp1->dev,
>  			"format type mismatch in link '%s:%d->%s:%d'\n",
>  			link->source->entity->name, link->source->index,
>
diff mbox series

Patch

diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c
index 24fe6a7888aa..01e1ff5943f1 100644
--- a/drivers/staging/media/rkisp1/rkisp1-capture.c
+++ b/drivers/staging/media/rkisp1/rkisp1-capture.c
@@ -52,7 +52,6 @@  enum rkisp1_plane {
  */
 struct rkisp1_capture_fmt_cfg {
 	u32 fourcc;
-	u8 fmt_type;
 	u8 uv_swap;
 	u32 write_format;
 	u32 output_format;
@@ -83,11 +82,24 @@  struct rkisp1_capture_config {
 	} mi;
 };
 
+static enum rkisp1_fmt_pix_type
+rkisp1_pixel_enc_to_fmt_pix(const struct v4l2_format_info *f)
+{
+	switch (f->pixel_enc) {
+	case V4L2_PIXEL_ENC_RGB:
+		return RKISP1_FMT_RGB;
+	case V4L2_PIXEL_ENC_YUV:
+		return RKISP1_FMT_YUV;
+	case V4L2_PIXEL_ENC_BAYER:
+		return RKISP1_FMT_BAYER;
+	}
+	return V4L2_PIXEL_ENC_UNKNOWN;
+}
+
 static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
 	/* yuv422 */
 	{
 		.fourcc = V4L2_PIX_FMT_YUYV,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
 	}, {
@@ -101,119 +113,95 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = {
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YUV422P,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV16,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV61,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YVU422M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	},
 	/* yuv420 */
 	{
 		.fourcc = V4L2_PIX_FMT_NV21,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV12,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV21M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV12M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_SPLA,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YUV420,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YVU420,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	},
 	/* yuv444 */
 	{
 		.fourcc = V4L2_PIX_FMT_YUV444M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	},
 	/* yuv400 */
 	{
 		.fourcc = V4L2_PIX_FMT_GREY,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT,
 	},
 	/* raw */
 	{
 		.fourcc = V4L2_PIX_FMT_SRGGB8,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGRBG8,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGBRG8,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SBGGR8,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_YUV_PLA_OR_RAW8,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SRGGB10,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGRBG10,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGBRG10,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SBGGR10,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SRGGB12,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGRBG12,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SGBRG12,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	}, {
 		.fourcc = V4L2_PIX_FMT_SBGGR12,
-		.fmt_type = RKISP1_FMT_BAYER,
 		.write_format = RKISP1_MI_CTRL_MP_WRITE_RAW12,
 	},
 };
@@ -222,7 +210,6 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 	/* yuv422 */
 	{
 		.fourcc = V4L2_PIX_FMT_YUYV,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_INT,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
@@ -240,25 +227,21 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YUV422P,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV16,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV61,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YVU422M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422,
@@ -266,37 +249,31 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 	/* yuv420 */
 	{
 		.fourcc = V4L2_PIX_FMT_NV21,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV12,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV21M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
 	}, {
 		.fourcc = V4L2_PIX_FMT_NV12M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_SPLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YUV420,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
 	}, {
 		.fourcc = V4L2_PIX_FMT_YVU420,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 1,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV420,
@@ -304,7 +281,6 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 	/* yuv444 */
 	{
 		.fourcc = V4L2_PIX_FMT_YUV444M,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV444,
@@ -312,7 +288,6 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 	/* yuv400 */
 	{
 		.fourcc = V4L2_PIX_FMT_GREY,
-		.fmt_type = RKISP1_FMT_YUV,
 		.uv_swap = 0,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_INT,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV400,
@@ -320,17 +295,14 @@  static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = {
 	/* rgb */
 	{
 		.fourcc = V4L2_PIX_FMT_RGB24,
-		.fmt_type = RKISP1_FMT_RGB,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB888,
 	}, {
 		.fourcc = V4L2_PIX_FMT_RGB565,
-		.fmt_type = RKISP1_FMT_RGB,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB565,
 	}, {
 		.fourcc = V4L2_PIX_FMT_BGR666,
-		.fmt_type = RKISP1_FMT_RGB,
 		.write_format = RKISP1_MI_CTRL_SP_WRITE_PLA,
 		.output_format = RKISP1_MI_CTRL_SP_OUTPUT_RGB666,
 	},
@@ -504,13 +476,12 @@  static void rkisp1_sp_disable(struct rkisp1_capture *cap)
 
 static void rkisp1_mp_enable(struct rkisp1_capture *cap)
 {
-	const struct rkisp1_capture_fmt_cfg *isp_fmt = cap->pix.cfg;
 	u32 mi_ctrl;
 
 	rkisp1_mp_disable(cap);
 
 	mi_ctrl = rkisp1_read(cap->rkisp1, RKISP1_CIF_MI_CTRL);
-	if (isp_fmt->fmt_type == RKISP1_FMT_BAYER)
+	if (v4l2_is_format_bayer(cap->pix.info))
 		mi_ctrl |= RKISP1_CIF_MI_CTRL_RAW_ENABLE;
 	/* YUV */
 	else
@@ -1260,7 +1231,8 @@  static int rkisp1_capture_link_validate(struct media_link *link)
 		return -EPIPE;
 	}
 
-	if (cap->pix.cfg->fmt_type != isp->src_fmt->fmt_type) {
+	if (rkisp1_pixel_enc_to_fmt_pix(cap->pix.info) !=
+	    isp->src_fmt->fmt_type) {
 		dev_err(cap->rkisp1->dev,
 			"format type mismatch in link '%s:%d->%s:%d'\n",
 			link->source->entity->name, link->source->index,