Commit fc9e78e6 authored by Laurent Pinchart's avatar Laurent Pinchart

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 105784bb
...@@ -728,20 +728,15 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -728,20 +728,15 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
/* Setup geometry, format, frame buffer memory and operation mode. */ /* Setup geometry, format, frame buffer memory and operation mode. */
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
const struct sh_mobile_lcdc_format_info *format;
u32 fourcc;
ch = &priv->ch[k]; ch = &priv->ch[k];
if (!ch->enabled) if (!ch->enabled)
continue; continue;
sh_mobile_lcdc_geometry(ch); sh_mobile_lcdc_geometry(ch);
fourcc = sh_mobile_format_fourcc(&ch->info->var); tmp = ch->format->lddfr;
format = sh_mobile_format_info(fourcc);
tmp = format->lddfr;
if (format->yuv) { if (ch->format->yuv) {
switch (ch->info->var.colorspace) { switch (ch->info->var.colorspace) {
case V4L2_COLORSPACE_REC709: case V4L2_COLORSPACE_REC709:
tmp |= LDDFR_CF1; tmp |= LDDFR_CF1;
...@@ -755,7 +750,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -755,7 +750,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
lcdc_write_chan(ch, LDDFR, tmp); lcdc_write_chan(ch, LDDFR, tmp);
lcdc_write_chan(ch, LDMLSR, ch->pitch); lcdc_write_chan(ch, LDMLSR, ch->pitch);
lcdc_write_chan(ch, LDSA1R, ch->base_addr_y); 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); lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
/* When using deferred I/O mode, configure the LCDC for one-shot /* When using deferred I/O mode, configure the LCDC for one-shot
...@@ -772,7 +767,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -772,7 +767,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
} }
/* Word and long word swap. */ /* 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_RGB565:
case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV61:
...@@ -859,7 +854,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) ...@@ -859,7 +854,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
ch->meram_enabled = 0; 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_NV12:
case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV16:
...@@ -1065,7 +1060,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var, ...@@ -1065,7 +1060,7 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
+ info->var.xres * info->var.yres_virtual + info->var.xres * info->var.yres_virtual
+ c_offset; + c_offset;
/* Set x 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; base_addr_c += 2 * var->xoffset;
else else
base_addr_c += var->xoffset; base_addr_c += var->xoffset;
...@@ -1353,6 +1348,8 @@ static int sh_mobile_set_par(struct fb_info *info) ...@@ -1353,6 +1348,8 @@ static int sh_mobile_set_par(struct fb_info *info)
info->fix.line_length = info->var.xres info->fix.line_length = info->var.xres
* info->var.bits_per_pixel / 8; * 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); ret = sh_mobile_lcdc_start(ch->lcdc);
if (ret < 0) { if (ret < 0) {
dev_err(info->dev, "%s: unable to restart LCDC\n", __func__); dev_err(info->dev, "%s: unable to restart LCDC\n", __func__);
...@@ -1716,6 +1713,8 @@ sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_priv *priv, ...@@ -1716,6 +1713,8 @@ sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_priv *priv,
return -EINVAL; return -EINVAL;
} }
ch->format = format;
/* Allocate the frame buffer device. */ /* Allocate the frame buffer device. */
ch->info = framebuffer_alloc(0, priv->dev); ch->info = framebuffer_alloc(0, priv->dev);
if (!ch->info) { if (!ch->info) {
......
...@@ -17,9 +17,10 @@ enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R, ...@@ -17,9 +17,10 @@ enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
struct backlight_device; struct backlight_device;
struct fb_info; struct fb_info;
struct module; struct module;
struct sh_mobile_lcdc_chan;
struct sh_mobile_lcdc_entity; struct sh_mobile_lcdc_entity;
struct sh_mobile_lcdc_format_info;
struct sh_mobile_lcdc_priv; struct sh_mobile_lcdc_priv;
struct sh_mobile_lcdc_chan;
#define SH_MOBILE_LCDC_DISPLAY_DISCONNECTED 0 #define SH_MOBILE_LCDC_DISPLAY_DISCONNECTED 0
#define SH_MOBILE_LCDC_DISPLAY_CONNECTED 1 #define SH_MOBILE_LCDC_DISPLAY_CONNECTED 1
...@@ -70,6 +71,7 @@ struct sh_mobile_lcdc_chan { ...@@ -70,6 +71,7 @@ struct sh_mobile_lcdc_chan {
wait_queue_head_t frame_end_wait; wait_queue_head_t frame_end_wait;
struct completion vsync_completion; struct completion vsync_completion;
const struct sh_mobile_lcdc_format_info *format;
unsigned long base_addr_y; unsigned long base_addr_y;
unsigned long base_addr_c; unsigned long base_addr_c;
unsigned int pitch; unsigned int pitch;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment