Commit e359b6a8 authored by Mike Rapoport's avatar Mike Rapoport Committed by Greg Kroah-Hartman

staging: sm750fb: merge lynx_share into sm750_dev

Both struct lynx_share and struct sm750_dev reprsent some parts of the
SM750 graphics adapter. There is no point to keep these parts in
different structures.
Signed-off-by: default avatarMike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8ac97f19
...@@ -165,7 +165,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info, ...@@ -165,7 +165,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
const struct fb_fillrect *region) const struct fb_fillrect *region)
{ {
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynx_share *share; struct sm750_dev *sm750_dev;
unsigned int base, pitch, Bpp, rop; unsigned int base, pitch, Bpp, rop;
u32 color; u32 color;
...@@ -173,7 +173,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info, ...@@ -173,7 +173,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
return; return;
par = info->par; par = info->par;
share = &par->dev->share; sm750_dev = par->dev;
/* /*
* each time 2d function begin to work,below three variable always need * each time 2d function begin to work,below three variable always need
...@@ -191,27 +191,27 @@ static void lynxfb_ops_fillrect(struct fb_info *info, ...@@ -191,27 +191,27 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
* If not use spin_lock,system will die if user load driver * If not use spin_lock,system will die if user load driver
* and immediately unload driver frequently (dual) * and immediately unload driver frequently (dual)
*/ */
if (share->dual) if (sm750_dev->dual)
spin_lock(&share->slock); spin_lock(&sm750_dev->slock);
share->accel.de_fillrect(&share->accel, sm750_dev->accel.de_fillrect(&sm750_dev->accel,
base, pitch, Bpp, base, pitch, Bpp,
region->dx, region->dy, region->dx, region->dy,
region->width, region->height, region->width, region->height,
color, rop); color, rop);
if (share->dual) if (sm750_dev->dual)
spin_unlock(&share->slock); spin_unlock(&sm750_dev->slock);
} }
static void lynxfb_ops_copyarea(struct fb_info *info, static void lynxfb_ops_copyarea(struct fb_info *info,
const struct fb_copyarea *region) const struct fb_copyarea *region)
{ {
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynx_share *share; struct sm750_dev *sm750_dev;
unsigned int base, pitch, Bpp; unsigned int base, pitch, Bpp;
par = info->par; par = info->par;
share = &par->dev->share; sm750_dev = par->dev;
/* /*
* each time 2d function begin to work,below three variable always need * each time 2d function begin to work,below three variable always need
...@@ -225,15 +225,16 @@ static void lynxfb_ops_copyarea(struct fb_info *info, ...@@ -225,15 +225,16 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
* If not use spin_lock, system will die if user load driver * If not use spin_lock, system will die if user load driver
* and immediately unload driver frequently (dual) * and immediately unload driver frequently (dual)
*/ */
if (share->dual) if (sm750_dev->dual)
spin_lock(&share->slock); spin_lock(&sm750_dev->slock);
share->accel.de_copyarea(&share->accel, sm750_dev->accel.de_copyarea(&sm750_dev->accel,
base, pitch, region->sx, region->sy, base, pitch, region->sx, region->sy,
base, pitch, Bpp, region->dx, region->dy, base, pitch, Bpp, region->dx, region->dy,
region->width, region->height, HW_ROP2_COPY); region->width, region->height,
if (share->dual) HW_ROP2_COPY);
spin_unlock(&share->slock); if (sm750_dev->dual)
spin_unlock(&sm750_dev->slock);
} }
static void lynxfb_ops_imageblit(struct fb_info *info, static void lynxfb_ops_imageblit(struct fb_info *info,
...@@ -242,10 +243,10 @@ static void lynxfb_ops_imageblit(struct fb_info *info, ...@@ -242,10 +243,10 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
unsigned int base, pitch, Bpp; unsigned int base, pitch, Bpp;
unsigned int fgcol, bgcol; unsigned int fgcol, bgcol;
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynx_share *share; struct sm750_dev *sm750_dev;
par = info->par; par = info->par;
share = &par->dev->share; sm750_dev = par->dev;
/* /*
* each time 2d function begin to work,below three variable always need * each time 2d function begin to work,below three variable always need
* be set, seems we can put them together in some place * be set, seems we can put them together in some place
...@@ -273,17 +274,17 @@ static void lynxfb_ops_imageblit(struct fb_info *info, ...@@ -273,17 +274,17 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
* If not use spin_lock, system will die if user load driver * If not use spin_lock, system will die if user load driver
* and immediately unload driver frequently (dual) * and immediately unload driver frequently (dual)
*/ */
if (share->dual) if (sm750_dev->dual)
spin_lock(&share->slock); spin_lock(&sm750_dev->slock);
share->accel.de_imageblit(&share->accel, sm750_dev->accel.de_imageblit(&sm750_dev->accel,
image->data, image->width >> 3, 0, image->data, image->width >> 3, 0,
base, pitch, Bpp, base, pitch, Bpp,
image->dx, image->dy, image->dx, image->dy,
image->width, image->height, image->width, image->height,
fgcol, bgcol, HW_ROP2_COPY); fgcol, bgcol, HW_ROP2_COPY);
if (share->dual) if (sm750_dev->dual)
spin_unlock(&share->slock); spin_unlock(&sm750_dev->slock);
} }
static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var, static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
...@@ -303,7 +304,6 @@ static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var, ...@@ -303,7 +304,6 @@ static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
static int lynxfb_ops_set_par(struct fb_info *info) static int lynxfb_ops_set_par(struct fb_info *info)
{ {
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynx_share *share;
struct lynxfb_crtc *crtc; struct lynxfb_crtc *crtc;
struct lynxfb_output *output; struct lynxfb_output *output;
struct fb_var_screeninfo *var; struct fb_var_screeninfo *var;
...@@ -316,7 +316,6 @@ static int lynxfb_ops_set_par(struct fb_info *info) ...@@ -316,7 +316,6 @@ static int lynxfb_ops_set_par(struct fb_info *info)
ret = 0; ret = 0;
par = info->par; par = info->par;
share = &par->dev->share;
crtc = &par->crtc; crtc = &par->crtc;
output = &par->output; output = &par->output;
var = &info->var; var = &info->var;
...@@ -396,7 +395,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) ...@@ -396,7 +395,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
{ {
struct fb_info *info; struct fb_info *info;
struct sm750_dev *sm750_dev; struct sm750_dev *sm750_dev;
struct lynx_share *share;
int ret; int ret;
if (mesg.event == pdev->dev.power.power_state.event) if (mesg.event == pdev->dev.power.power_state.event)
...@@ -404,7 +402,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) ...@@ -404,7 +402,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
ret = 0; ret = 0;
sm750_dev = pci_get_drvdata(pdev); sm750_dev = pci_get_drvdata(pdev);
share = &sm750_dev->share;
switch (mesg.event) { switch (mesg.event) {
case PM_EVENT_FREEZE: case PM_EVENT_FREEZE:
case PM_EVENT_PRETHAW: case PM_EVENT_PRETHAW:
...@@ -414,11 +411,11 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) ...@@ -414,11 +411,11 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
console_lock(); console_lock();
if (mesg.event & PM_EVENT_SLEEP) { if (mesg.event & PM_EVENT_SLEEP) {
info = share->fbinfo[0]; info = sm750_dev->fbinfo[0];
if (info) if (info)
/* 1 means do suspend */ /* 1 means do suspend */
fb_set_suspend(info, 1); fb_set_suspend(info, 1);
info = share->fbinfo[1]; info = sm750_dev->fbinfo[1];
if (info) if (info)
/* 1 means do suspend */ /* 1 means do suspend */
fb_set_suspend(info, 1); fb_set_suspend(info, 1);
...@@ -445,7 +442,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) ...@@ -445,7 +442,6 @@ static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
static int lynxfb_resume(struct pci_dev *pdev) static int lynxfb_resume(struct pci_dev *pdev)
{ {
struct fb_info *info; struct fb_info *info;
struct lynx_share *share;
struct sm750_dev *sm750_dev; struct sm750_dev *sm750_dev;
struct lynxfb_par *par; struct lynxfb_par *par;
...@@ -456,7 +452,6 @@ static int lynxfb_resume(struct pci_dev *pdev) ...@@ -456,7 +452,6 @@ static int lynxfb_resume(struct pci_dev *pdev)
ret = 0; ret = 0;
sm750_dev = pci_get_drvdata(pdev); sm750_dev = pci_get_drvdata(pdev);
share = &sm750_dev->share;
console_lock(); console_lock();
...@@ -478,7 +473,7 @@ static int lynxfb_resume(struct pci_dev *pdev) ...@@ -478,7 +473,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
hw_sm750_inithw(sm750_dev, pdev); hw_sm750_inithw(sm750_dev, pdev);
info = share->fbinfo[0]; info = sm750_dev->fbinfo[0];
if (info) { if (info) {
par = info->par; par = info->par;
...@@ -490,7 +485,7 @@ static int lynxfb_resume(struct pci_dev *pdev) ...@@ -490,7 +485,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
fb_set_suspend(info, 0); fb_set_suspend(info, 0);
} }
info = share->fbinfo[1]; info = sm750_dev->fbinfo[1];
if (info) { if (info) {
par = info->par; par = info->par;
...@@ -514,13 +509,11 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var, ...@@ -514,13 +509,11 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynxfb_crtc *crtc; struct lynxfb_crtc *crtc;
struct lynxfb_output *output; struct lynxfb_output *output;
struct lynx_share *share;
resource_size_t request; resource_size_t request;
par = info->par; par = info->par;
crtc = &par->crtc; crtc = &par->crtc;
output = &par->output; output = &par->output;
share = &par->dev->share;
pr_debug("check var:%dx%d-%d\n", pr_debug("check var:%dx%d-%d\n",
var->xres, var->xres,
...@@ -649,7 +642,6 @@ static int lynxfb_ops_blank(int blank, struct fb_info *info) ...@@ -649,7 +642,6 @@ static int lynxfb_ops_blank(int blank, struct fb_info *info)
static int sm750fb_set_drv(struct lynxfb_par *par) static int sm750fb_set_drv(struct lynxfb_par *par)
{ {
int ret; int ret;
struct lynx_share *share;
struct sm750_dev *sm750_dev; struct sm750_dev *sm750_dev;
struct lynxfb_output *output; struct lynxfb_output *output;
struct lynxfb_crtc *crtc; struct lynxfb_crtc *crtc;
...@@ -657,12 +649,11 @@ static int sm750fb_set_drv(struct lynxfb_par *par) ...@@ -657,12 +649,11 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
ret = 0; ret = 0;
sm750_dev = par->dev; sm750_dev = par->dev;
share = &sm750_dev->share;
output = &par->output; output = &par->output;
crtc = &par->crtc; crtc = &par->crtc;
crtc->vidmem_size = (share->dual) ? share->vidmem_size >> 1 : crtc->vidmem_size = (sm750_dev->dual) ? sm750_dev->vidmem_size >> 1 :
share->vidmem_size; sm750_dev->vidmem_size;
/* setup crtc and output member */ /* setup crtc and output member */
sm750_dev->hwCursor = g_hwcursor; sm750_dev->hwCursor = g_hwcursor;
...@@ -671,37 +662,37 @@ static int sm750fb_set_drv(struct lynxfb_par *par) ...@@ -671,37 +662,37 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
crtc->ypanstep = 1; crtc->ypanstep = 1;
crtc->ywrapstep = 0; crtc->ywrapstep = 0;
output->proc_setBLANK = (share->revid == SM750LE_REVISION_ID) ? output->proc_setBLANK = (sm750_dev->revid == SM750LE_REVISION_ID) ?
hw_sm750le_setBLANK : hw_sm750_setBLANK; hw_sm750le_setBLANK : hw_sm750_setBLANK;
/* chip specific phase */ /* chip specific phase */
share->accel.de_wait = (share->revid == SM750LE_REVISION_ID) ? sm750_dev->accel.de_wait = (sm750_dev->revid == SM750LE_REVISION_ID) ?
hw_sm750le_deWait : hw_sm750_deWait; hw_sm750le_deWait : hw_sm750_deWait;
switch (sm750_dev->dataflow) { switch (sm750_dev->dataflow) {
case sm750_simul_pri: case sm750_simul_pri:
output->paths = sm750_pnc; output->paths = sm750_pnc;
crtc->channel = sm750_primary; crtc->channel = sm750_primary;
crtc->oScreen = 0; crtc->oScreen = 0;
crtc->vScreen = share->pvMem; crtc->vScreen = sm750_dev->pvMem;
pr_info("use simul primary mode\n"); pr_info("use simul primary mode\n");
break; break;
case sm750_simul_sec: case sm750_simul_sec:
output->paths = sm750_pnc; output->paths = sm750_pnc;
crtc->channel = sm750_secondary; crtc->channel = sm750_secondary;
crtc->oScreen = 0; crtc->oScreen = 0;
crtc->vScreen = share->pvMem; crtc->vScreen = sm750_dev->pvMem;
break; break;
case sm750_dual_normal: case sm750_dual_normal:
if (par->index == 0) { if (par->index == 0) {
output->paths = sm750_panel; output->paths = sm750_panel;
crtc->channel = sm750_primary; crtc->channel = sm750_primary;
crtc->oScreen = 0; crtc->oScreen = 0;
crtc->vScreen = share->pvMem; crtc->vScreen = sm750_dev->pvMem;
} else { } else {
output->paths = sm750_crt; output->paths = sm750_crt;
crtc->channel = sm750_secondary; crtc->channel = sm750_secondary;
/* not consider of padding stuffs for oScreen,need fix */ /* not consider of padding stuffs for oScreen,need fix */
crtc->oScreen = (share->vidmem_size >> 1); crtc->oScreen = (sm750_dev->vidmem_size >> 1);
crtc->vScreen = share->pvMem + crtc->oScreen; crtc->vScreen = sm750_dev->pvMem + crtc->oScreen;
} }
break; break;
case sm750_dual_swap: case sm750_dual_swap:
...@@ -709,13 +700,13 @@ static int sm750fb_set_drv(struct lynxfb_par *par) ...@@ -709,13 +700,13 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
output->paths = sm750_panel; output->paths = sm750_panel;
crtc->channel = sm750_secondary; crtc->channel = sm750_secondary;
crtc->oScreen = 0; crtc->oScreen = 0;
crtc->vScreen = share->pvMem; crtc->vScreen = sm750_dev->pvMem;
} else { } else {
output->paths = sm750_crt; output->paths = sm750_crt;
crtc->channel = sm750_primary; crtc->channel = sm750_primary;
/* not consider of padding stuffs for oScreen,need fix */ /* not consider of padding stuffs for oScreen,need fix */
crtc->oScreen = (share->vidmem_size >> 1); crtc->oScreen = (sm750_dev->vidmem_size >> 1);
crtc->vScreen = share->pvMem + crtc->oScreen; crtc->vScreen = sm750_dev->pvMem + crtc->oScreen;
} }
break; break;
default: default:
...@@ -742,7 +733,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -742,7 +733,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
{ {
int i; int i;
struct lynxfb_par *par; struct lynxfb_par *par;
struct lynx_share *share; struct sm750_dev *sm750_dev;
struct lynxfb_crtc *crtc; struct lynxfb_crtc *crtc;
struct lynxfb_output *output; struct lynxfb_output *output;
struct fb_var_screeninfo *var; struct fb_var_screeninfo *var;
...@@ -766,7 +757,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -766,7 +757,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
ret = 0; ret = 0;
par = (struct lynxfb_par *)info->par; par = (struct lynxfb_par *)info->par;
share = &par->dev->share; sm750_dev = par->dev;
crtc = &par->crtc; crtc = &par->crtc;
output = &par->output; output = &par->output;
var = &info->var; var = &info->var;
...@@ -783,12 +774,13 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -783,12 +774,13 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
* must be set after crtc member initialized * must be set after crtc member initialized
*/ */
crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024; crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024;
crtc->cursor.mmio = share->pvReg + 0x800f0 + (int)crtc->channel * 0x140; crtc->cursor.mmio = sm750_dev->pvReg +
0x800f0 + (int)crtc->channel * 0x140;
pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio); pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
crtc->cursor.maxH = crtc->cursor.maxW = 64; crtc->cursor.maxH = crtc->cursor.maxW = 64;
crtc->cursor.size = crtc->cursor.maxH * crtc->cursor.maxW * 2 / 8; crtc->cursor.size = crtc->cursor.maxH * crtc->cursor.maxW * 2 / 8;
crtc->cursor.vstart = share->pvMem + crtc->cursor.offset; crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset;
memset_io(crtc->cursor.vstart, 0, crtc->cursor.size); memset_io(crtc->cursor.vstart, 0, crtc->cursor.size);
if (!g_hwcursor) { if (!g_hwcursor) {
...@@ -797,7 +789,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -797,7 +789,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
} }
/* set info->fbops, must be set before fb_find_mode */ /* set info->fbops, must be set before fb_find_mode */
if (!share->accel_off) { if (!sm750_dev->accel_off) {
/* use 2d acceleration */ /* use 2d acceleration */
lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect; lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea; lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
...@@ -880,7 +872,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -880,7 +872,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
strlcpy(fix->id, fixId[index], sizeof(fix->id)); strlcpy(fix->id, fixId[index], sizeof(fix->id));
fix->smem_start = crtc->oScreen + share->vidmem_start; fix->smem_start = crtc->oScreen + sm750_dev->vidmem_start;
pr_info("fix->smem_start = %lx\n", fix->smem_start); pr_info("fix->smem_start = %lx\n", fix->smem_start);
/* /*
* according to mmap experiment from user space application, * according to mmap experiment from user space application,
...@@ -893,9 +885,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -893,9 +885,9 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
pr_info("fix->smem_len = %x\n", fix->smem_len); pr_info("fix->smem_len = %x\n", fix->smem_len);
info->screen_size = fix->smem_len; info->screen_size = fix->smem_len;
fix->line_length = line_length; fix->line_length = line_length;
fix->mmio_start = share->vidreg_start; fix->mmio_start = sm750_dev->vidreg_start;
pr_info("fix->mmio_start = %lx\n", fix->mmio_start); pr_info("fix->mmio_start = %lx\n", fix->mmio_start);
fix->mmio_len = share->vidreg_size; fix->mmio_len = sm750_dev->vidreg_size;
pr_info("fix->mmio_len = %x\n", fix->mmio_len); pr_info("fix->mmio_len = %x\n", fix->mmio_len);
switch (var->bits_per_pixel) { switch (var->bits_per_pixel) {
case 8: case 8:
...@@ -936,7 +928,6 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) ...@@ -936,7 +928,6 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
/* chip specific g_option configuration routine */ /* chip specific g_option configuration routine */
static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
{ {
struct lynx_share *share = &sm750_dev->share;
char *opt; char *opt;
#ifdef CAP_EXPENSION #ifdef CAP_EXPENSION
char *exp_res; char *exp_res;
...@@ -1009,8 +1000,8 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) ...@@ -1009,8 +1000,8 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
#endif #endif
NO_PARAM: NO_PARAM:
if (share->revid != SM750LE_REVISION_ID) { if (sm750_dev->revid != SM750LE_REVISION_ID) {
if (share->dual) { if (sm750_dev->dual) {
if (swap) if (swap)
sm750_dev->dataflow = sm750_dual_swap; sm750_dev->dataflow = sm750_dual_swap;
else else
...@@ -1033,10 +1024,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1033,10 +1024,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct fb_info *info[] = {NULL, NULL}; struct fb_info *info[] = {NULL, NULL};
struct lynx_share *share = NULL;
struct sm750_dev *sm750_dev = NULL; struct sm750_dev *sm750_dev = NULL;
size_t spec_offset = 0;
int fbidx; int fbidx;
/* enable device */ /* enable device */
...@@ -1045,43 +1033,35 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1045,43 +1033,35 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
goto err_enable; goto err_enable;
} }
/*
* though offset of share in sm750_dev is 0,
* we use this marcro as the same
*/
spec_offset = offsetof(struct sm750_dev, share);
sm750_dev = kzalloc(sizeof(*sm750_dev), GFP_KERNEL); sm750_dev = kzalloc(sizeof(*sm750_dev), GFP_KERNEL);
if (!sm750_dev) { if (!sm750_dev) {
pr_err("Could not allocate memory for share.\n"); pr_err("Could not allocate memory for share.\n");
goto err_share; goto err_share;
} }
/* setting share structure */ sm750_dev->fbinfo[0] = sm750_dev->fbinfo[1] = NULL;
share = (struct lynx_share *)(&(sm750_dev->share)); sm750_dev->devid = pdev->device;
share->fbinfo[0] = share->fbinfo[1] = NULL; sm750_dev->revid = pdev->revision;
share->devid = pdev->device;
share->revid = pdev->revision; pr_info("share->revid = %02x\n", sm750_dev->revid);
sm750_dev->pdev = pdev;
pr_info("share->revid = %02x\n", share->revid); sm750_dev->mtrr_off = g_nomtrr;
share->pdev = pdev; sm750_dev->mtrr.vram = 0;
share->mtrr_off = g_nomtrr; sm750_dev->accel_off = g_noaccel;
share->mtrr.vram = 0; sm750_dev->dual = g_dualview;
share->accel_off = g_noaccel; spin_lock_init(&sm750_dev->slock);
share->dual = g_dualview;
spin_lock_init(&share->slock); if (!sm750_dev->accel_off) {
if (!share->accel_off) {
/* /*
* hook deInit and 2d routines, notes that below hw_xxx * hook deInit and 2d routines, notes that below hw_xxx
* routine can work on most of lynx chips * routine can work on most of lynx chips
* if some chip need specific function, * if some chip need specific function,
* please hook it in smXXX_set_drv routine * please hook it in smXXX_set_drv routine
*/ */
share->accel.de_init = hw_de_init; sm750_dev->accel.de_init = hw_de_init;
share->accel.de_fillrect = hw_fillrect; sm750_dev->accel.de_fillrect = hw_fillrect;
share->accel.de_copyarea = hw_copyarea; sm750_dev->accel.de_copyarea = hw_copyarea;
share->accel.de_imageblit = hw_imageblit; sm750_dev->accel.de_imageblit = hw_imageblit;
pr_info("enable 2d acceleration\n"); pr_info("enable 2d acceleration\n");
} else { } else {
pr_info("disable 2d acceleration\n"); pr_info("disable 2d acceleration\n");
...@@ -1096,13 +1076,14 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1096,13 +1076,14 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
goto err_map; goto err_map;
} }
if (!share->mtrr_off) if (!sm750_dev->mtrr_off)
share->mtrr.vram = arch_phys_wc_add(share->vidmem_start, sm750_dev->mtrr.vram = arch_phys_wc_add(sm750_dev->vidmem_start,
share->vidmem_size); sm750_dev->vidmem_size);
memset_io(share->pvMem, 0, share->vidmem_size); memset_io(sm750_dev->pvMem, 0, sm750_dev->vidmem_size);
pr_info("sm%3x mmio address = %p\n", share->devid, share->pvReg); pr_info("sm%3x mmio address = %p\n", sm750_dev->devid,
sm750_dev->pvReg);
pci_set_drvdata(pdev, sm750_dev); pci_set_drvdata(pdev, sm750_dev);
...@@ -1124,7 +1105,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1124,7 +1105,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
int errno; int errno;
pr_info("framebuffer #%d alloc okay\n", fbidx); pr_info("framebuffer #%d alloc okay\n", fbidx);
share->fbinfo[fbidx] = info[fbidx]; sm750_dev->fbinfo[fbidx] = info[fbidx];
par = info[fbidx]->par; par = info[fbidx]->par;
par->dev = sm750_dev; par->dev = sm750_dev;
...@@ -1154,7 +1135,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1154,7 +1135,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
/* no dual view by far */ /* no dual view by far */
fbidx++; fbidx++;
if (share->dual && fbidx < 2) if (sm750_dev->dual && fbidx < 2)
goto ALLOC_FB; goto ALLOC_FB;
return 0; return 0;
...@@ -1178,17 +1159,15 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, ...@@ -1178,17 +1159,15 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
static void lynxfb_pci_remove(struct pci_dev *pdev) static void lynxfb_pci_remove(struct pci_dev *pdev)
{ {
struct fb_info *info; struct fb_info *info;
struct lynx_share *share;
struct sm750_dev *sm750_dev; struct sm750_dev *sm750_dev;
struct lynxfb_par *par; struct lynxfb_par *par;
int cnt; int cnt;
cnt = 2; cnt = 2;
sm750_dev = pci_get_drvdata(pdev); sm750_dev = pci_get_drvdata(pdev);
share = &sm750_dev->share;
while (cnt-- > 0) { while (cnt-- > 0) {
info = share->fbinfo[cnt]; info = sm750_dev->fbinfo[cnt];
if (!info) if (!info)
continue; continue;
par = info->par; par = info->par;
...@@ -1197,10 +1176,10 @@ static void lynxfb_pci_remove(struct pci_dev *pdev) ...@@ -1197,10 +1176,10 @@ static void lynxfb_pci_remove(struct pci_dev *pdev)
/* release frame buffer */ /* release frame buffer */
framebuffer_release(info); framebuffer_release(info);
} }
arch_phys_wc_del(share->mtrr.vram); arch_phys_wc_del(sm750_dev->mtrr.vram);
iounmap(share->pvReg); iounmap(sm750_dev->pvReg);
iounmap(share->pvMem); iounmap(sm750_dev->pvMem);
kfree(g_settings); kfree(g_settings);
kfree(sm750_dev); kfree(sm750_dev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
......
...@@ -71,10 +71,7 @@ struct lynx_accel { ...@@ -71,10 +71,7 @@ struct lynx_accel {
}; };
/* lynx_share stands for a presentation of two frame buffer struct sm750_dev {
that use one smi adaptor , it is similar to a basic class of C++
*/
struct lynx_share {
/* common members */ /* common members */
u16 devid; u16 devid;
u8 revid; u8 revid;
...@@ -83,10 +80,10 @@ struct lynx_share { ...@@ -83,10 +80,10 @@ struct lynx_share {
struct lynx_accel accel; struct lynx_accel accel;
int accel_off; int accel_off;
int dual; int dual;
int mtrr_off; int mtrr_off;
struct{ struct{
int vram; int vram;
} mtrr; } mtrr;
/* all smi graphic adaptor got below attributes */ /* all smi graphic adaptor got below attributes */
unsigned long vidmem_start; unsigned long vidmem_start;
unsigned long vidreg_start; unsigned long vidreg_start;
...@@ -96,14 +93,6 @@ struct lynx_share { ...@@ -96,14 +93,6 @@ struct lynx_share {
unsigned char __iomem *pvMem; unsigned char __iomem *pvMem;
/* locks*/ /* locks*/
spinlock_t slock; spinlock_t slock;
};
/*
* sm750_dev stands for a presentation of two frame buffer
* that use one sm750 adaptor
*/
struct sm750_dev {
struct lynx_share share;
struct init_status initParm; struct init_status initParm;
enum sm750_pnltype pnltype; enum sm750_pnltype pnltype;
......
...@@ -27,14 +27,13 @@ ...@@ -27,14 +27,13 @@
int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
{ {
int ret; int ret;
struct lynx_share *share = &sm750_dev->share;
ret = 0; ret = 0;
share->vidreg_start = pci_resource_start(pdev, 1); sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
share->vidreg_size = SZ_2M; sm750_dev->vidreg_size = SZ_2M;
pr_info("mmio phyAddr = %lx\n", share->vidreg_start); pr_info("mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
/* reserve the vidreg space of smi adaptor /* reserve the vidreg space of smi adaptor
* if you do this, u need to add release region code * if you do this, u need to add release region code
...@@ -48,40 +47,41 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) ...@@ -48,40 +47,41 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
} }
/* now map mmio and vidmem*/ /* now map mmio and vidmem*/
share->pvReg = ioremap_nocache(share->vidreg_start, share->vidreg_size); sm750_dev->pvReg = ioremap_nocache(sm750_dev->vidreg_start,
if (!share->pvReg) { sm750_dev->vidreg_size);
if (!sm750_dev->pvReg) {
pr_err("mmio failed\n"); pr_err("mmio failed\n");
ret = -EFAULT; ret = -EFAULT;
goto exit; goto exit;
} else { } else {
pr_info("mmio virtual addr = %p\n", share->pvReg); pr_info("mmio virtual addr = %p\n", sm750_dev->pvReg);
} }
share->accel.dprBase = share->pvReg + DE_BASE_ADDR_TYPE1; sm750_dev->accel.dprBase = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
share->accel.dpPortBase = share->pvReg + DE_PORT_ADDR_TYPE1; sm750_dev->accel.dpPortBase = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
ddk750_set_mmio(share->pvReg, share->devid, share->revid); ddk750_set_mmio(sm750_dev->pvReg, sm750_dev->devid, sm750_dev->revid);
share->vidmem_start = pci_resource_start(pdev, 0); sm750_dev->vidmem_start = pci_resource_start(pdev, 0);
/* don't use pdev_resource[x].end - resource[x].start to /* don't use pdev_resource[x].end - resource[x].start to
* calculate the resource size,its only the maximum available * calculate the resource size,its only the maximum available
* size but not the actual size,use * size but not the actual size,use
* @ddk750_getVMSize function can be safe. * @ddk750_getVMSize function can be safe.
* */ * */
share->vidmem_size = ddk750_getVMSize(); sm750_dev->vidmem_size = ddk750_getVMSize();
pr_info("video memory phyAddr = %lx, size = %u bytes\n", pr_info("video memory phyAddr = %lx, size = %u bytes\n",
share->vidmem_start, share->vidmem_size); sm750_dev->vidmem_start, sm750_dev->vidmem_size);
/* reserve the vidmem space of smi adaptor */ /* reserve the vidmem space of smi adaptor */
share->pvMem = ioremap_wc(share->vidmem_start, share->vidmem_size); sm750_dev->pvMem = ioremap_wc(sm750_dev->vidmem_start,
sm750_dev->vidmem_size);
if (!share->pvMem) { if (!sm750_dev->pvMem) {
pr_err("Map video memory failed\n"); pr_err("Map video memory failed\n");
ret = -EFAULT; ret = -EFAULT;
goto exit; goto exit;
} else { } else {
pr_info("video memory vaddr = %p\n", share->pvMem); pr_info("video memory vaddr = %p\n", sm750_dev->pvMem);
} }
exit: exit:
return ret; return ret;
...@@ -91,7 +91,6 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) ...@@ -91,7 +91,6 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev) int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
{ {
struct lynx_share *share = &sm750_dev->share;
struct init_status *parm; struct init_status *parm;
parm = &sm750_dev->initParm; parm = &sm750_dev->initParm;
...@@ -107,7 +106,7 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev) ...@@ -107,7 +106,7 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
ddk750_initHw((initchip_param_t *)&sm750_dev->initParm); ddk750_initHw((initchip_param_t *)&sm750_dev->initParm);
/* for sm718,open pci burst */ /* for sm718,open pci burst */
if (share->devid == 0x718) { if (sm750_dev->devid == 0x718) {
POKE32(SYSTEM_CTRL, POKE32(SYSTEM_CTRL,
FIELD_SET(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, PCI_BURST, ON)); FIELD_SET(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, PCI_BURST, ON));
} }
...@@ -171,7 +170,7 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev) ...@@ -171,7 +170,7 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
} }
/* init 2d engine */ /* init 2d engine */
if (!share->accel_off) if (!sm750_dev->accel_off)
hw_sm750_initAccel(sm750_dev); hw_sm750_initAccel(sm750_dev);
return 0; return 0;
...@@ -221,17 +220,17 @@ int hw_sm750_output_setMode(struct lynxfb_output *output, ...@@ -221,17 +220,17 @@ int hw_sm750_output_setMode(struct lynxfb_output *output,
int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc, struct fb_var_screeninfo *var) int hw_sm750_crtc_checkMode(struct lynxfb_crtc *crtc, struct fb_var_screeninfo *var)
{ {
struct lynx_share *share; struct sm750_dev *sm750_dev;
struct lynxfb_par *par = container_of(crtc, struct lynxfb_par, crtc); struct lynxfb_par *par = container_of(crtc, struct lynxfb_par, crtc);
share = &par->dev->share; sm750_dev = par->dev;
switch (var->bits_per_pixel) { switch (var->bits_per_pixel) {
case 8: case 8:
case 16: case 16:
break; break;
case 32: case 32:
if (share->revid == SM750LE_REVISION_ID) { if (sm750_dev->revid == SM750LE_REVISION_ID) {
pr_debug("750le do not support 32bpp\n"); pr_debug("750le do not support 32bpp\n");
return -EINVAL; return -EINVAL;
} }
...@@ -256,15 +255,15 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, ...@@ -256,15 +255,15 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
u32 reg; u32 reg;
mode_parameter_t modparm; mode_parameter_t modparm;
clock_type_t clock; clock_type_t clock;
struct lynx_share *share; struct sm750_dev *sm750_dev;
struct lynxfb_par *par; struct lynxfb_par *par;
ret = 0; ret = 0;
par = container_of(crtc, struct lynxfb_par, crtc); par = container_of(crtc, struct lynxfb_par, crtc);
share = &par->dev->share; sm750_dev = par->dev;
if (!share->accel_off) { if (!sm750_dev->accel_off) {
/* set 2d engine pixel format according to mode bpp */ /* set 2d engine pixel format according to mode bpp */
switch (var->bits_per_pixel) { switch (var->bits_per_pixel) {
case 8: case 8:
...@@ -278,7 +277,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, ...@@ -278,7 +277,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc,
fmt = 2; fmt = 2;
break; break;
} }
hw_set2dformat(&share->accel, fmt); hw_set2dformat(&sm750_dev->accel, fmt);
} }
/* set timing */ /* set timing */
...@@ -463,7 +462,6 @@ int hw_sm750_setBLANK(struct lynxfb_output *output, int blank) ...@@ -463,7 +462,6 @@ int hw_sm750_setBLANK(struct lynxfb_output *output, int blank)
void hw_sm750_initAccel(struct sm750_dev *sm750_dev) void hw_sm750_initAccel(struct sm750_dev *sm750_dev)
{ {
struct lynx_share *share = &sm750_dev->share;
u32 reg; u32 reg;
enable2DEngine(1); enable2DEngine(1);
...@@ -489,7 +487,7 @@ void hw_sm750_initAccel(struct sm750_dev *sm750_dev) ...@@ -489,7 +487,7 @@ void hw_sm750_initAccel(struct sm750_dev *sm750_dev)
} }
/* call 2d init */ /* call 2d init */
share->accel.de_init(&share->accel); sm750_dev->accel.de_init(&sm750_dev->accel);
} }
int hw_sm750le_deWait(void) int hw_sm750le_deWait(void)
......
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