};
int ret;
- cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY, true);
+ cc = imx_media_find_format(fsize->pixel_format, CS_SEL_ANY);
if (!cc)
return -EINVAL;
};
int ret;
- cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY, true);
+ cc = imx_media_find_format(fival->pixel_format, CS_SEL_ANY);
if (!cc)
return -EINVAL;
return ret;
}
- cc_src = imx_media_find_ipu_format(fmt_src.format.code, CS_SEL_ANY);
+ cc_src = imx_media_find_ipu_format(fmt_src.format.code,
+ CS_SEL_YUV_RGB);
if (cc_src) {
u32 cs_sel = (cc_src->cs == IPUV3_COLORSPACE_YUV) ?
CS_SEL_YUV : CS_SEL_RGB;
return ret;
} else {
cc_src = imx_media_find_mbus_format(fmt_src.format.code,
- CS_SEL_ANY, true);
+ CS_SEL_ANY);
if (WARN_ON(!cc_src))
return -EINVAL;
{
const struct imx_media_pixfmt *cc, *cc_src;
- cc_src = imx_media_find_ipu_format(fmt_src->format.code, CS_SEL_ANY);
+ cc_src = imx_media_find_ipu_format(fmt_src->format.code,
+ CS_SEL_YUV_RGB);
if (cc_src) {
u32 fourcc, cs_sel;
CS_SEL_YUV : CS_SEL_RGB;
fourcc = f->fmt.pix.pixelformat;
- cc = imx_media_find_format(fourcc, cs_sel, false);
+ cc = imx_media_find_format(fourcc, cs_sel);
if (!cc) {
imx_media_enum_format(&fourcc, 0, cs_sel);
- cc = imx_media_find_format(fourcc, cs_sel, false);
+ cc = imx_media_find_format(fourcc, cs_sel);
}
} else {
cc_src = imx_media_find_mbus_format(fmt_src->format.code,
- CS_SEL_ANY, true);
+ CS_SEL_ANY);
if (WARN_ON(!cc_src))
return -EINVAL;
vdev->compose.width = fmt_src.format.width;
vdev->compose.height = fmt_src.format.height;
vdev->cc = imx_media_find_format(vdev->fmt.fmt.pix.pixelformat,
- CS_SEL_ANY, false);
+ CS_SEL_YUV_RGB);
v4l2_info(sd, "Registered %s as /dev/%s\n", vfd->name,
video_device_node_name(vfd));
static const struct imx_media_pixfmt *find_format(u32 fourcc,
u32 code,
enum codespace_sel cs_sel,
- bool allow_non_mbus,
- bool allow_bayer)
+ bool allow_non_mbus)
{
unsigned int i;
enum codespace_sel fmt_cs_sel;
unsigned int j;
- fmt_cs_sel = (fmt->cs == IPUV3_COLORSPACE_YUV) ?
- CS_SEL_YUV : CS_SEL_RGB;
+ fmt_cs_sel = fmt->bayer ? CS_SEL_BAYER :
+ ((fmt->cs == IPUV3_COLORSPACE_YUV) ?
+ CS_SEL_YUV : CS_SEL_RGB);
- if ((cs_sel != CS_SEL_ANY && fmt_cs_sel != cs_sel) ||
- (!allow_non_mbus && !fmt->codes[0]) ||
- (!allow_bayer && fmt->bayer))
+ if (!(fmt_cs_sel & cs_sel) ||
+ (!allow_non_mbus && !fmt->codes[0]))
continue;
if (fourcc && fmt->fourcc == fourcc)
static int enum_format(u32 *fourcc, u32 *code, u32 index,
enum codespace_sel cs_sel,
- bool allow_non_mbus,
- bool allow_bayer)
+ bool allow_non_mbus)
{
unsigned int i;
enum codespace_sel fmt_cs_sel;
unsigned int j;
- fmt_cs_sel = (fmt->cs == IPUV3_COLORSPACE_YUV) ?
- CS_SEL_YUV : CS_SEL_RGB;
+ fmt_cs_sel = fmt->bayer ? CS_SEL_BAYER :
+ ((fmt->cs == IPUV3_COLORSPACE_YUV) ?
+ CS_SEL_YUV : CS_SEL_RGB);
- if ((cs_sel != CS_SEL_ANY && fmt_cs_sel != cs_sel) ||
- (!allow_non_mbus && !fmt->codes[0]) ||
- (!allow_bayer && fmt->bayer))
+ if (!(fmt_cs_sel & cs_sel) ||
+ (!allow_non_mbus && !fmt->codes[0]))
continue;
if (fourcc && index == 0) {
}
const struct imx_media_pixfmt *
-imx_media_find_format(u32 fourcc, enum codespace_sel cs_sel, bool allow_bayer)
+imx_media_find_format(u32 fourcc, enum codespace_sel cs_sel)
{
- return find_format(fourcc, 0, cs_sel, true, allow_bayer);
+ return find_format(fourcc, 0, cs_sel, true);
}
EXPORT_SYMBOL_GPL(imx_media_find_format);
int imx_media_enum_format(u32 *fourcc, u32 index, enum codespace_sel cs_sel)
{
- return enum_format(fourcc, NULL, index, cs_sel, true, false);
+ return enum_format(fourcc, NULL, index, cs_sel, true);
}
EXPORT_SYMBOL_GPL(imx_media_enum_format);
const struct imx_media_pixfmt *
-imx_media_find_mbus_format(u32 code, enum codespace_sel cs_sel,
- bool allow_bayer)
+imx_media_find_mbus_format(u32 code, enum codespace_sel cs_sel)
{
- return find_format(0, code, cs_sel, false, allow_bayer);
+ return find_format(0, code, cs_sel, false);
}
EXPORT_SYMBOL_GPL(imx_media_find_mbus_format);
-int imx_media_enum_mbus_format(u32 *code, u32 index, enum codespace_sel cs_sel,
- bool allow_bayer)
+int imx_media_enum_mbus_format(u32 *code, u32 index, enum codespace_sel cs_sel)
{
- return enum_format(NULL, code, index, cs_sel, false, allow_bayer);
+ return enum_format(NULL, code, index, cs_sel, false);
}
EXPORT_SYMBOL_GPL(imx_media_enum_mbus_format);
u32 array_size;
int i, j;
+ cs_sel &= ~CS_SEL_BAYER;
+
switch (cs_sel) {
case CS_SEL_YUV:
array_size = NUM_IPU_YUV_FORMATS;
array_size = NUM_IPU_RGB_FORMATS;
array = ipu_rgb_formats;
break;
- case CS_SEL_ANY:
+ case CS_SEL_YUV_RGB:
array_size = NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS;
array = ipu_yuv_formats;
break;
}
for (i = 0; i < array_size; i++) {
- if (cs_sel == CS_SEL_ANY && i >= NUM_IPU_YUV_FORMATS)
+ if (cs_sel == CS_SEL_YUV_RGB && i >= NUM_IPU_YUV_FORMATS)
fmt = &ipu_rgb_formats[i - NUM_IPU_YUV_FORMATS];
else
fmt = &array[i];
int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel)
{
+ cs_sel &= ~CS_SEL_BAYER;
+
switch (cs_sel) {
case CS_SEL_YUV:
if (index >= NUM_IPU_YUV_FORMATS)
return -EINVAL;
*code = ipu_rgb_formats[index].codes[0];
break;
- case CS_SEL_ANY:
+ case CS_SEL_YUV_RGB:
if (index >= NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS)
return -EINVAL;
if (index >= NUM_IPU_YUV_FORMATS) {
mbus->height = height;
mbus->field = field;
if (code == 0)
- imx_media_enum_mbus_format(&code, 0, CS_SEL_YUV, false);
- lcc = imx_media_find_mbus_format(code, CS_SEL_ANY, false);
+ imx_media_enum_mbus_format(&code, 0, CS_SEL_YUV);
+ lcc = imx_media_find_mbus_format(code, CS_SEL_YUV_RGB);
if (!lcc) {
- lcc = imx_media_find_ipu_format(code, CS_SEL_ANY);
+ lcc = imx_media_find_ipu_format(code, CS_SEL_YUV_RGB);
if (!lcc)
return -EINVAL;
}
const struct imx_media_pixfmt *cc;
bool is_rgb = false;
- cc = imx_media_find_mbus_format(tryfmt->code, CS_SEL_ANY, true);
+ cc = imx_media_find_mbus_format(tryfmt->code, CS_SEL_ANY);
if (!cc)
- cc = imx_media_find_ipu_format(tryfmt->code, CS_SEL_ANY);
+ cc = imx_media_find_ipu_format(tryfmt->code, CS_SEL_YUV_RGB);
if (cc && cc->cs == IPUV3_COLORSPACE_RGB)
is_rgb = true;
u32 stride;
if (!cc) {
- cc = imx_media_find_ipu_format(mbus->code, CS_SEL_ANY);
+ cc = imx_media_find_ipu_format(mbus->code, CS_SEL_YUV_RGB);
if (!cc)
- cc = imx_media_find_mbus_format(mbus->code, CS_SEL_ANY,
- true);
+ cc = imx_media_find_mbus_format(mbus->code,
+ CS_SEL_ANY);
if (!cc)
return -EINVAL;
}
if (cc->ipufmt && cc->cs == IPUV3_COLORSPACE_YUV) {
u32 code;
- imx_media_enum_mbus_format(&code, 0, CS_SEL_YUV, false);
- cc = imx_media_find_mbus_format(code, CS_SEL_YUV, false);
+ imx_media_enum_mbus_format(&code, 0, CS_SEL_YUV);
+ cc = imx_media_find_mbus_format(code, CS_SEL_YUV);
}
/* Round up width for minimum burst size */
{
const struct imx_media_pixfmt *fmt;
- fmt = imx_media_find_format(image->pix.pixelformat, CS_SEL_ANY, true);
+ fmt = imx_media_find_format(image->pix.pixelformat, CS_SEL_ANY);
if (!fmt)
return -EINVAL;