@@ -16,6 +16,12 @@
#define RWPF_MIN_WIDTH 1
#define RWPF_MIN_HEIGHT 1
+static const u32 rwpf_mbus_codes[] = {
+ MEDIA_BUS_FMT_ARGB8888_1X32,
+ MEDIA_BUS_FMT_AHSV8888_1X32,
+ MEDIA_BUS_FMT_AYUV8_1X32,
+};
+
/* -----------------------------------------------------------------------------
* V4L2 Subdevice Operations
*/
@@ -24,16 +30,10 @@ static int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
- static const unsigned int codes[] = {
- MEDIA_BUS_FMT_ARGB8888_1X32,
- MEDIA_BUS_FMT_AHSV8888_1X32,
- MEDIA_BUS_FMT_AYUV8_1X32,
- };
-
- if (code->index >= ARRAY_SIZE(codes))
+ if (code->index >= ARRAY_SIZE(rwpf_mbus_codes))
return -EINVAL;
- code->code = codes[code->index];
+ code->code = rwpf_mbus_codes[code->index];
return 0;
}
@@ -57,6 +57,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
struct vsp1_rwpf *rwpf = to_rwpf(subdev);
struct v4l2_subdev_state *state;
struct v4l2_mbus_framefmt *format;
+ unsigned int i;
int ret = 0;
mutex_lock(&rwpf->entity.lock);
@@ -68,9 +69,11 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
}
/* Default to YUV if the requested format is not supported. */
- if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 &&
- fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 &&
- fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32)
+ for (i = 0; i < ARRAY_SIZE(rwpf_mbus_codes); ++i) {
+ if (fmt->format.code == rwpf_mbus_codes[i])
+ break;
+ }
+ if (i == ARRAY_SIZE(rwpf_mbus_codes))
fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32;
format = v4l2_subdev_state_get_format(state, fmt->pad);