@@ -902,6 +902,15 @@ static inline bool sensor_is_preferred(const struct isc_format *isc_fmt)
902902 !isc_fmt -> isc_support ;
903903}
904904
905+ static inline u32 get_preferred_mbus_code (const struct isc_device * isc ,
906+ const struct isc_format * isc_fmt )
907+ {
908+ if (sensor_is_preferred (isc_fmt ) || !isc -> raw_fmt )
909+ return isc_fmt -> mbus_code ;
910+ else
911+ return isc -> raw_fmt -> mbus_code ;
912+ }
913+
905914static struct fmt_config * get_fmt_config (u32 fourcc )
906915{
907916 struct fmt_config * config ;
@@ -955,7 +964,7 @@ static void isc_set_pipeline(struct isc_device *isc, u32 pipeline)
955964{
956965 struct regmap * regmap = isc -> regmap ;
957966 struct isc_ctrls * ctrls = & isc -> ctrls ;
958- struct fmt_config * config = get_fmt_config ( isc -> raw_fmt -> fourcc ) ;
967+ struct fmt_config * config ;
959968 u32 val , bay_cfg ;
960969 const u32 * gamma ;
961970 unsigned int i ;
@@ -969,7 +978,12 @@ static void isc_set_pipeline(struct isc_device *isc, u32 pipeline)
969978 if (!pipeline )
970979 return ;
971980
972- bay_cfg = config -> cfa_baycfg ;
981+ if (isc -> raw_fmt ) {
982+ config = get_fmt_config (isc -> raw_fmt -> fourcc );
983+ bay_cfg = config -> cfa_baycfg ;
984+ } else {
985+ bay_cfg = 0 ;
986+ }
973987
974988 regmap_write (regmap , ISC_WB_CFG , bay_cfg );
975989 regmap_write (regmap , ISC_WB_O_RGR , 0x0 );
@@ -1022,12 +1036,20 @@ static void isc_set_histogram(struct isc_device *isc)
10221036{
10231037 struct regmap * regmap = isc -> regmap ;
10241038 struct isc_ctrls * ctrls = & isc -> ctrls ;
1025- struct fmt_config * config = get_fmt_config (isc -> raw_fmt -> fourcc );
1039+ struct fmt_config * config ;
1040+ u32 cfa_baycfg ;
1041+
1042+ if (isc -> raw_fmt ) {
1043+ config = get_fmt_config (isc -> raw_fmt -> fourcc );
1044+ cfa_baycfg = config -> cfa_baycfg << ISC_HIS_CFG_BAYSEL_SHIFT ;
1045+ } else {
1046+ cfa_baycfg = 0 ;
1047+ }
10261048
10271049 if (ctrls -> awb && (ctrls -> hist_stat != HIST_ENABLED )) {
10281050 regmap_write (regmap , ISC_HIS_CFG ,
10291051 ISC_HIS_CFG_MODE_R |
1030- ( config -> cfa_baycfg << ISC_HIS_CFG_BAYSEL_SHIFT ) |
1052+ cfa_baycfg |
10311053 ISC_HIS_CFG_RAR );
10321054 regmap_write (regmap , ISC_HIS_CTRL , ISC_HIS_CTRL_EN );
10331055 regmap_write (regmap , ISC_INTEN , ISC_INT_HISDONE );
@@ -1075,7 +1097,7 @@ static int isc_configure(struct isc_device *isc)
10751097 struct regmap * regmap = isc -> regmap ;
10761098 const struct isc_format * current_fmt = isc -> current_fmt ;
10771099 struct fmt_config * curfmt_config = get_fmt_config (current_fmt -> fourcc );
1078- struct fmt_config * rawfmt_config = get_fmt_config ( isc -> raw_fmt -> fourcc ) ;
1100+ struct fmt_config * rawfmt_config ;
10791101 struct isc_subdev_entity * subdev = isc -> current_subdev ;
10801102 u32 pfe_cfg0 , rlp_mode , dcfg , mask , pipeline ;
10811103
@@ -1085,7 +1107,12 @@ static int isc_configure(struct isc_device *isc)
10851107 isc_get_param (current_fmt , & rlp_mode , & dcfg );
10861108 isc -> ctrls .hist_stat = HIST_INIT ;
10871109 } else {
1088- pfe_cfg0 = rawfmt_config -> pfe_cfg0_bps ;
1110+ if (isc -> raw_fmt ) {
1111+ rawfmt_config = get_fmt_config (isc -> raw_fmt -> fourcc );
1112+ pfe_cfg0 = rawfmt_config -> pfe_cfg0_bps ;
1113+ } else {
1114+ pfe_cfg0 = curfmt_config -> pfe_cfg0_bps ;
1115+ }
10891116 pipeline = curfmt_config -> bits_pipeline ;
10901117 rlp_mode = curfmt_config -> rlp_cfg_mode ;
10911118 dcfg = curfmt_config -> dcfg_imode |
@@ -1315,10 +1342,7 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
13151342 if (pixfmt -> height > ISC_MAX_SUPPORT_HEIGHT )
13161343 pixfmt -> height = ISC_MAX_SUPPORT_HEIGHT ;
13171344
1318- if (sensor_is_preferred (isc_fmt ))
1319- mbus_code = isc_fmt -> mbus_code ;
1320- else
1321- mbus_code = isc -> raw_fmt -> mbus_code ;
1345+ mbus_code = get_preferred_mbus_code (isc , isc_fmt );
13221346
13231347 v4l2_fill_mbus_format (& format .format , pixfmt , mbus_code );
13241348 ret = v4l2_subdev_call (isc -> current_subdev -> sd , pad , set_fmt ,
@@ -1448,10 +1472,7 @@ static int isc_enum_framesizes(struct file *file, void *fh,
14481472 if (!isc_fmt )
14491473 return - EINVAL ;
14501474
1451- if (sensor_is_preferred (isc_fmt ))
1452- fse .code = isc_fmt -> mbus_code ;
1453- else
1454- fse .code = isc -> raw_fmt -> mbus_code ;
1475+ fse .code = get_preferred_mbus_code (isc , isc_fmt );
14551476
14561477 ret = v4l2_subdev_call (isc -> current_subdev -> sd , pad , enum_frame_size ,
14571478 NULL , & fse );
@@ -1482,10 +1503,7 @@ static int isc_enum_frameintervals(struct file *file, void *fh,
14821503 if (!isc_fmt )
14831504 return - EINVAL ;
14841505
1485- if (sensor_is_preferred (isc_fmt ))
1486- fie .code = isc_fmt -> mbus_code ;
1487- else
1488- fie .code = isc -> raw_fmt -> mbus_code ;
1506+ fie .code = get_preferred_mbus_code (isc , isc_fmt );
14891507
14901508 ret = v4l2_subdev_call (isc -> current_subdev -> sd , pad ,
14911509 enum_frame_interval , NULL , & fie );
@@ -1674,7 +1692,7 @@ static void isc_awb_work(struct work_struct *w)
16741692 struct isc_device * isc =
16751693 container_of (w , struct isc_device , awb_work );
16761694 struct regmap * regmap = isc -> regmap ;
1677- struct fmt_config * config = get_fmt_config ( isc -> raw_fmt -> fourcc ) ;
1695+ struct fmt_config * config ;
16781696 struct isc_ctrls * ctrls = & isc -> ctrls ;
16791697 u32 hist_id = ctrls -> hist_id ;
16801698 u32 baysel ;
@@ -1692,7 +1710,13 @@ static void isc_awb_work(struct work_struct *w)
16921710 }
16931711
16941712 ctrls -> hist_id = hist_id ;
1695- baysel = config -> cfa_baycfg << ISC_HIS_CFG_BAYSEL_SHIFT ;
1713+
1714+ if (isc -> raw_fmt ) {
1715+ config = get_fmt_config (isc -> raw_fmt -> fourcc );
1716+ baysel = config -> cfa_baycfg << ISC_HIS_CFG_BAYSEL_SHIFT ;
1717+ } else {
1718+ baysel = 0 ;
1719+ }
16961720
16971721 pm_runtime_get_sync (isc -> dev );
16981722
0 commit comments