Commit ca5d8440 authored by Petr Vandrovec's avatar Petr Vandrovec

Simplify rules for writting secondary output drivers to matroxfb.

Update some initializations to use C99 initializers.
parent 4bbbb253
......@@ -504,37 +504,8 @@ static int m1064_compute(void* outdev, struct my_timming* m) {
return 0;
}
static int m1064_program(void* outdev) {
/* nothing, hardware is set in m1064_compute */
return 0;
}
static int m1064_start(void* outdev) {
/* nothing */
return 0;
}
static void m1064_incuse(void* outdev) {
/* nothing yet; MODULE_INC_USE in future... */
}
static void m1064_decuse(void* outdev) {
/* nothing yet; MODULE_DEC_USE in future... */
}
static int m1064_setmode(void* outdev, u_int32_t mode) {
if (mode != MATROXFB_OUTPUT_MODE_MONITOR)
return -EINVAL;
return 0;
}
static struct matrox_altout m1064 = {
m1064_compute,
m1064_program,
m1064_start,
m1064_incuse,
m1064_decuse,
m1064_setmode
.compute = m1064_compute,
};
#endif /* NEED_DAC1064 */
......
......@@ -825,34 +825,34 @@ static int matroxfb_set_var(struct fb_var_screeninfo *var, int con,
hw->CRTCEXT[0] = (hw->CRTCEXT[0] & 0xF0) | ((pos >> 16) & 0x0F) | ((pos >> 14) & 0x40);
hw->CRTCEXT[8] = pos >> 21;
if (ACCESS_FBINFO(output.ph) & (MATROXFB_OUTPUT_CONN_PRIMARY | MATROXFB_OUTPUT_CONN_DFP)) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->compute)
ACCESS_FBINFO(primout)->compute(MINFO, &mt);
}
if (ACCESS_FBINFO(output.ph) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->compute)
ACCESS_FBINFO(altout.output)->compute(ACCESS_FBINFO(altout.device), &mt);
up_read(&ACCESS_FBINFO(altout.lock));
}
ACCESS_FBINFO(hw_switch->restore(PMINFO display));
if (ACCESS_FBINFO(output.ph) & (MATROXFB_OUTPUT_CONN_PRIMARY | MATROXFB_OUTPUT_CONN_DFP)) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->program)
ACCESS_FBINFO(primout)->program(MINFO);
}
if (ACCESS_FBINFO(output.ph) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->program)
ACCESS_FBINFO(altout.output)->program(ACCESS_FBINFO(altout.device));
up_read(&ACCESS_FBINFO(altout.lock));
}
ACCESS_FBINFO(cursor.redraw) = 1;
if (ACCESS_FBINFO(output.ph) & (MATROXFB_OUTPUT_CONN_PRIMARY | MATROXFB_OUTPUT_CONN_DFP)) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->start)
ACCESS_FBINFO(primout)->start(MINFO);
}
if (ACCESS_FBINFO(output.ph) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->start)
ACCESS_FBINFO(altout.output)->start(ACCESS_FBINFO(altout.device));
up_read(&ACCESS_FBINFO(altout.lock));
}
......@@ -1006,11 +1006,21 @@ static int matroxfb_ioctl(struct inode *inode, struct file *file,
case MATROXFB_OUTPUT_SECONDARY:
val = -EINVAL;
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.device))
val = ACCESS_FBINFO(altout.output)->setmode(ACCESS_FBINFO(altout.device), mom.mode);
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.device)) {
if (ACCESS_FBINFO(altout.output)->verifymode) {
val = ACCESS_FBINFO(altout.output)->verifymode(ACCESS_FBINFO(altout.device), mom.mode);
} else {
if (mom.mode == MATROXFB_OUTPUT_MODE_MONITOR) {
val = 0;
}
}
}
up_read(&ACCESS_FBINFO(altout.lock));
if (val != 1)
if (val != 0)
return val;
if (ACCESS_FBINFO(altout.mode) == mom.mode)
return 0;
ACCESS_FBINFO(altout.mode) = mom.mode;
if (ACCESS_FBINFO(output.ph) & MATROXFB_OUTPUT_CONN_SECONDARY)
matroxfb_switch(ACCESS_FBINFO(fbcon.currcon), info);
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_SECONDARY) {
......@@ -1051,8 +1061,10 @@ static int matroxfb_ioctl(struct inode *inode, struct file *file,
case MATROXFB_OUTPUT_SECONDARY:
val = -EINVAL;
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.device))
val = ACCESS_FBINFO(altout.output)->getmode(ACCESS_FBINFO(altout.device), &mom.mode);
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.device)) {
mom.mode = ACCESS_FBINFO(altout.mode);
val = 0;
}
up_read(&ACCESS_FBINFO(altout.lock));
if (val)
return val;
......
......@@ -399,10 +399,7 @@ struct matrox_altout {
int (*compute)(void* altout_dev, struct my_timming* input);
int (*program)(void* altout_dev);
int (*start)(void* altout_dev);
void (*incuse)(void* altout_dev);
void (*decuse)(void* altout_dev);
int (*setmode)(void* altout_dev, u_int32_t mode);
int (*getmode)(void* altout_dev, u_int32_t* mode);
int (*verifymode)(void* altout_dev, u_int32_t mode);
};
enum mga_chip { MGA_2064, MGA_2164, MGA_1064, MGA_1164, MGA_G100, MGA_G200, MGA_G400, MGA_G450, MGA_G550 };
......@@ -452,6 +449,7 @@ struct matrox_fb_info {
struct matrox_altout* output;
void* device;
struct rw_semaphore lock;
unsigned int mode;
} altout;
#define MATROXFB_MAX_FB_DRIVERS 5
......
......@@ -420,34 +420,34 @@ static int matroxfb_dh_set_var(struct fb_var_screeninfo* var, int con,
pos += m2info->video.offbase;
DAC1064_global_init(PMINFO2);
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_PRIMARY) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->compute)
ACCESS_FBINFO(primout)->compute(MINFO, &mt);
}
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->compute)
ACCESS_FBINFO(altout.output)->compute(ACCESS_FBINFO(altout.device), &mt);
up_read(&ACCESS_FBINFO(altout.lock));
}
matroxfb_dh_restore(m2info, &mt, p, mode, pos);
DAC1064_global_restore(PMINFO2);
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_PRIMARY) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->program)
ACCESS_FBINFO(primout)->program(MINFO);
}
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->program)
ACCESS_FBINFO(altout.output)->program(ACCESS_FBINFO(altout.device));
up_read(&ACCESS_FBINFO(altout.lock));
}
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_PRIMARY) {
if (ACCESS_FBINFO(primout))
if (ACCESS_FBINFO(primout) && ACCESS_FBINFO(primout)->start)
ACCESS_FBINFO(primout)->start(MINFO);
}
if (ACCESS_FBINFO(output.sh) & MATROXFB_OUTPUT_CONN_SECONDARY) {
down_read(&ACCESS_FBINFO(altout.lock));
if (ACCESS_FBINFO(altout.output))
if (ACCESS_FBINFO(altout.output) && ACCESS_FBINFO(altout.output)->start)
ACCESS_FBINFO(altout.output)->start(ACCESS_FBINFO(altout.device));
up_read(&ACCESS_FBINFO(altout.lock));
}
......
......@@ -33,38 +33,9 @@ static int matroxfb_g450_program(void* md) {
return 0;
}
static int matroxfb_g450_start(void* md) {
return 0;
}
static void matroxfb_g450_incuse(void* md) {
MOD_INC_USE_COUNT;
}
static void matroxfb_g450_decuse(void* md) {
MOD_DEC_USE_COUNT;
}
static int matroxfb_g450_set_mode(void* md, u_int32_t arg) {
if (arg == MATROXFB_OUTPUT_MODE_MONITOR) {
return 1;
}
return -EINVAL;
}
static int matroxfb_g450_get_mode(void* md, u_int32_t* arg) {
*arg = MATROXFB_OUTPUT_MODE_MONITOR;
return 0;
}
static struct matrox_altout matroxfb_g450_altout = {
matroxfb_g450_compute,
matroxfb_g450_program,
matroxfb_g450_start,
matroxfb_g450_incuse,
matroxfb_g450_decuse,
matroxfb_g450_set_mode,
matroxfb_g450_get_mode
.compute = matroxfb_g450_compute,
.program = matroxfb_g450_program,
};
void matroxfb_g450_connect(WPMINFO2) {
......
......@@ -33,7 +33,6 @@
struct maven_data {
struct matrox_fb_info* primary_head;
struct i2c_client* client;
int mode;
int version;
};
......@@ -326,8 +325,9 @@ static void maven_init_TVdata(const struct maven_data* md, struct mavenregs* dat
0x00, /* 3E written multiple times */
0x00, /* never written */
}, MODE_NTSC, 525, 60 };
if (md->mode & MODE_PAL)
MINFO_FROM(md->primary_head);
if (ACCESS_FBINFO(altout.mode) == MODE_PAL)
*data = palregs;
else
*data = ntscregs;
......@@ -583,9 +583,10 @@ static inline int maven_compute_timming(struct maven_data* md,
struct mavenregs* m) {
unsigned int tmpi;
unsigned int a, bv, c;
MINFO_FROM(md->primary_head);
m->mode = md->mode;
if (MODE_TV(md->mode)) {
m->mode = ACCESS_FBINFO(altout.mode);
if (MODE_TV(m->mode)) {
unsigned int lmargin;
unsigned int umargin;
unsigned int vslen;
......@@ -855,22 +856,16 @@ static inline int maven_resync(struct maven_data* md) {
return 0;
}
static int maven_set_output_mode(struct maven_data* md, u_int32_t arg) {
static int maven_verify_output_mode(struct maven_data* md, u_int32_t arg) {
switch (arg) {
case MATROXFB_OUTPUT_MODE_PAL:
case MATROXFB_OUTPUT_MODE_NTSC:
case MATROXFB_OUTPUT_MODE_MONITOR:
md->mode = arg;
return 1;
return 0;
}
return -EINVAL;
}
static int maven_get_output_mode(struct maven_data* md, u_int32_t *arg) {
*arg = md->mode;
return 0;
}
/******************************************************/
static int maven_out_compute(void* md, struct my_timming* mt) {
......@@ -893,32 +888,15 @@ static int maven_out_start(void* md) {
return maven_resync(md);
}
static void maven_out_incuse(void* md) {
if (md)
i2c_inc_use_client(((struct maven_data*)md)->client);
}
static void maven_out_decuse(void* md) {
if (md)
i2c_dec_use_client(((struct maven_data*)md)->client);
}
static int maven_out_set_mode(void* md, u_int32_t arg) {
return maven_set_output_mode(md, arg);
}
static int maven_out_get_mode(void* md, u_int32_t* arg) {
return maven_get_output_mode(md, arg);
static int maven_out_verify_mode(void* md, u_int32_t arg) {
return maven_verify_output_mode(md, arg);
}
static struct matrox_altout maven_altout = {
maven_out_compute,
maven_out_program,
maven_out_start,
maven_out_incuse,
maven_out_decuse,
maven_out_set_mode,
maven_out_get_mode
.compute = maven_out_compute,
.program = maven_out_program,
.start = maven_out_start,
.verifymode = maven_out_verify_mode,
};
static int maven_init_client(struct i2c_client* clnt) {
......@@ -926,7 +904,7 @@ static int maven_init_client(struct i2c_client* clnt) {
struct maven_data* md = clnt->data;
MINFO_FROM(((struct i2c_bit_adapter*)a)->minfo);
md->mode = MODE_MONITOR;
ACCESS_FBINFO(altout.mode) = MODE_MONITOR;
md->primary_head = MINFO;
md->client = clnt;
down_write(&ACCESS_FBINFO(altout.lock));
......
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