@@ -670,6 +670,20 @@ static const struct v4l2_ctrl_ops imx219_ctrl_ops = {
670
670
.s_ctrl = imx219_set_ctrl ,
671
671
};
672
672
673
+ static void imx219_update_pad_format (struct imx219 * imx219 ,
674
+ const struct imx219_mode * mode ,
675
+ struct v4l2_mbus_framefmt * fmt , u32 code )
676
+ {
677
+ /* Bayer order varies with flips */
678
+ fmt -> code = imx219_get_format_code (imx219 , code );
679
+ fmt -> width = mode -> width ;
680
+ fmt -> height = mode -> height ;
681
+ fmt -> field = V4L2_FIELD_NONE ;
682
+ fmt -> colorspace = V4L2_COLORSPACE_RAW ;
683
+ fmt -> quantization = V4L2_QUANTIZATION_FULL_RANGE ;
684
+ fmt -> xfer_func = V4L2_XFER_FUNC_NONE ;
685
+ }
686
+
673
687
static int imx219_init_cfg (struct v4l2_subdev * sd ,
674
688
struct v4l2_subdev_state * state )
675
689
{
@@ -679,15 +693,8 @@ static int imx219_init_cfg(struct v4l2_subdev *sd,
679
693
680
694
/* Initialize try_fmt */
681
695
format = v4l2_subdev_get_pad_format (sd , state , 0 );
682
- format -> width = supported_modes [0 ].width ;
683
- format -> height = supported_modes [0 ].height ;
684
- format -> code = imx219_get_format_code (imx219 ,
685
- MEDIA_BUS_FMT_SRGGB10_1X10 );
686
- format -> field = V4L2_FIELD_NONE ;
687
- format -> colorspace = V4L2_COLORSPACE_RAW ;
688
- format -> ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT (format -> colorspace );
689
- format -> quantization = V4L2_QUANTIZATION_FULL_RANGE ;
690
- format -> xfer_func = V4L2_XFER_FUNC_NONE ;
696
+ imx219_update_pad_format (imx219 , & supported_modes [0 ], format ,
697
+ MEDIA_BUS_FMT_SRGGB10_1X10 );
691
698
692
699
/* Initialize crop rectangle. */
693
700
crop = v4l2_subdev_get_pad_crop (sd , state , 0 );
@@ -735,23 +742,6 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd,
735
742
return 0 ;
736
743
}
737
744
738
- static void imx219_reset_colorspace (struct v4l2_mbus_framefmt * fmt )
739
- {
740
- fmt -> colorspace = V4L2_COLORSPACE_RAW ;
741
- fmt -> quantization = V4L2_QUANTIZATION_FULL_RANGE ;
742
- fmt -> xfer_func = V4L2_XFER_FUNC_NONE ;
743
- }
744
-
745
- static void imx219_update_pad_format (struct imx219 * imx219 ,
746
- const struct imx219_mode * mode ,
747
- struct v4l2_subdev_format * fmt )
748
- {
749
- fmt -> format .width = mode -> width ;
750
- fmt -> format .height = mode -> height ;
751
- fmt -> format .field = V4L2_FIELD_NONE ;
752
- imx219_reset_colorspace (& fmt -> format );
753
- }
754
-
755
745
static int imx219_set_pad_format (struct v4l2_subdev * sd ,
756
746
struct v4l2_subdev_state * sd_state ,
757
747
struct v4l2_subdev_format * fmt )
@@ -768,15 +758,13 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
768
758
if (i >= ARRAY_SIZE (imx219_mbus_formats ))
769
759
i = 0 ;
770
760
771
- /* Bayer order varies with flips */
772
- fmt -> format .code = imx219_get_format_code (imx219 , imx219_mbus_formats [i ]);
773
-
774
761
mode = v4l2_find_nearest_size (supported_modes ,
775
762
ARRAY_SIZE (supported_modes ),
776
763
width , height ,
777
764
fmt -> format .width , fmt -> format .height );
778
765
779
- imx219_update_pad_format (imx219 , mode , fmt );
766
+ imx219_update_pad_format (imx219 , mode , & fmt -> format ,
767
+ imx219_mbus_formats [i ]);
780
768
format = v4l2_subdev_get_pad_format (sd , sd_state , 0 );
781
769
782
770
if (imx219 -> mode == mode && format -> code == fmt -> format .code )
0 commit comments