fbdev: sh_mobile_lcdc: Store the format in struct sh_mobile_lcdc_chan
Store the active format in the channel structure, and use it instead of
parsing info->var all over the place when the format is needed.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index c66f0f4..6d8c30b 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -728,20 +728,15 @@
/* Setup geometry, format, frame buffer memory and operation mode. */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
- const struct sh_mobile_lcdc_format_info *format;
- u32 fourcc;
-
ch = &priv->ch[k];
if (!ch->enabled)
continue;
sh_mobile_lcdc_geometry(ch);
- fourcc = sh_mobile_format_fourcc(&ch->info->var);
- format = sh_mobile_format_info(fourcc);
- tmp = format->lddfr;
+ tmp = ch->format->lddfr;
- if (format->yuv) {
+ if (ch->format->yuv) {
switch (ch->info->var.colorspace) {
case V4L2_COLORSPACE_REC709:
tmp |= LDDFR_CF1;
@@ -755,7 +750,7 @@
lcdc_write_chan(ch, LDDFR, tmp);
lcdc_write_chan(ch, LDMLSR, ch->pitch);
lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
- if (format->yuv)
+ if (ch->format->yuv)
lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
/* When using deferred I/O mode, configure the LCDC for one-shot
@@ -772,7 +767,7 @@
}
/* Word and long word swap. */
- switch (sh_mobile_format_fourcc(&priv->ch[0].info->var)) {
+ switch (priv->ch[0].format->fourcc) {
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV61:
@@ -859,7 +854,7 @@
ch->meram_enabled = 0;
}
- switch (sh_mobile_format_fourcc(&ch->info->var)) {
+ switch (ch->format->fourcc) {
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16:
@@ -1065,7 +1060,7 @@
+ info->var.xres * info->var.yres_virtual
+ c_offset;
/* Set x offset */
- if (sh_mobile_format_fourcc(&info->var) == V4L2_PIX_FMT_NV24)
+ if (ch->format->fourcc == V4L2_PIX_FMT_NV24)
base_addr_c += 2 * var->xoffset;
else
base_addr_c += var->xoffset;
@@ -1353,6 +1348,8 @@
info->fix.line_length = info->var.xres
* info->var.bits_per_pixel / 8;
+ ch->format = sh_mobile_format_info(sh_mobile_format_fourcc(&info->var));
+
ret = sh_mobile_lcdc_start(ch->lcdc);
if (ret < 0) {
dev_err(info->dev, "%s: unable to restart LCDC\n", __func__);
@@ -1716,6 +1713,8 @@
return -EINVAL;
}
+ ch->format = format;
+
/* Allocate the frame buffer device. */
ch->info = framebuffer_alloc(0, priv->dev);
if (!ch->info) {