Commit 48110050 authored by Laurent Pinchart's avatar Laurent Pinchart

fbdev: sh_mobile_meram: Allocate ICBs automatically

Instead of manually specifying the ICBs to use in platform data,
allocate them automatically at runtime. The range of reserved ICBs (for
instance to be used through UIO), if any, is passed in the platform data
reserved_icbs field as a bitmask.

The MERAM registration function now returns a pointer to an opaque MERAM
object, which is passed to the update and unregistration functions.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 974d250b
......@@ -840,6 +840,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
struct sh_mobile_meram_cfg *cfg;
int pixelformat;
void *meram;
ch = &priv->ch[k];
if (!ch->enabled)
......@@ -856,9 +857,9 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
/* we need to de-init configured ICBs before we can
* re-initialize them.
*/
if (ch->meram_enabled) {
mdev->ops->meram_unregister(mdev, cfg);
ch->meram_enabled = 0;
if (ch->meram) {
mdev->ops->meram_unregister(mdev, ch->meram);
ch->meram = NULL;
}
switch (ch->format->fourcc) {
......@@ -880,13 +881,13 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
break;
}
ret = mdev->ops->meram_register(mdev, cfg, ch->pitch,
meram = mdev->ops->meram_register(mdev, cfg, ch->pitch,
ch->yres, pixelformat,
ch->base_addr_y, ch->base_addr_c,
&ch->base_addr_y, &ch->base_addr_c,
&ch->pitch);
if (!ret)
ch->meram_enabled = 1;
if (!IS_ERR(meram))
ch->meram = meram;
}
/* Start the LCDC. */
......@@ -951,13 +952,11 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
sh_mobile_lcdc_display_off(ch);
/* disable the meram */
if (ch->meram_enabled) {
struct sh_mobile_meram_cfg *cfg;
if (ch->meram) {
struct sh_mobile_meram_info *mdev;
cfg = ch->cfg.meram_cfg;
mdev = priv->meram_dev;
mdev->ops->meram_unregister(mdev, cfg);
ch->meram_enabled = 0;
mdev->ops->meram_unregister(mdev, ch->meram);
ch->meram = 0;
}
}
......@@ -1070,14 +1069,12 @@ static int sh_mobile_fb_pan_display(struct fb_var_screeninfo *var,
base_addr_c += var->xoffset;
}
if (ch->meram_enabled) {
struct sh_mobile_meram_cfg *cfg;
if (ch->meram) {
struct sh_mobile_meram_info *mdev;
int ret;
cfg = ch->cfg.meram_cfg;
mdev = priv->meram_dev;
ret = mdev->ops->meram_update(mdev, cfg,
ret = mdev->ops->meram_update(mdev, ch->meram,
base_addr_y, base_addr_c,
&base_addr_y, &base_addr_c);
if (ret)
......
......@@ -59,7 +59,7 @@ struct sh_mobile_lcdc_chan {
unsigned long *reg_offs;
unsigned long ldmt1r_value;
unsigned long enabled; /* ME and SE in LDCNT2R */
int meram_enabled;
void *meram;
struct mutex open_lock; /* protects the use counter */
int use_count;
......
This diff is collapsed.
......@@ -17,8 +17,13 @@ enum {
struct sh_mobile_meram_priv;
struct sh_mobile_meram_ops;
/*
* struct sh_mobile_meram_info - MERAM platform data
* @reserved_icbs: Bitmask of reserved ICBs (for instance used through UIO)
*/
struct sh_mobile_meram_info {
int addr_mode;
u32 reserved_icbs;
struct sh_mobile_meram_ops *ops;
struct sh_mobile_meram_priv *priv;
struct platform_device *pdev;
......@@ -39,23 +44,23 @@ struct module;
struct sh_mobile_meram_ops {
struct module *module;
/* register usage of meram */
int (*meram_register)(struct sh_mobile_meram_info *meram_dev,
const struct sh_mobile_meram_cfg *cfg,
unsigned int xres, unsigned int yres,
unsigned int pixelformat,
unsigned long base_addr_y,
unsigned long base_addr_c,
unsigned long *icb_addr_y,
unsigned long *icb_addr_c,
unsigned int *pitch);
void *(*meram_register)(struct sh_mobile_meram_info *meram_dev,
const struct sh_mobile_meram_cfg *cfg,
unsigned int xres, unsigned int yres,
unsigned int pixelformat,
unsigned long base_addr_y,
unsigned long base_addr_c,
unsigned long *icb_addr_y,
unsigned long *icb_addr_c,
unsigned int *pitch);
/* unregister usage of meram */
int (*meram_unregister)(struct sh_mobile_meram_info *meram_dev,
const struct sh_mobile_meram_cfg *cfg);
void *data);
/* update meram settings */
int (*meram_update)(struct sh_mobile_meram_info *meram_dev,
const struct sh_mobile_meram_cfg *cfg,
void *data,
unsigned long base_addr_y,
unsigned long base_addr_c,
unsigned long *icb_addr_y,
......
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