20 #include <asm/div64.h>
33 static const struct mctl g450_controls[] =
61 #define G450CTRLS ARRAY_SIZE(g450_controls)
66 static int get_ctrl_id(
__u32 v4l2_id) {
70 if (v4l2_id < g450_controls[i].
desc.id) {
71 if (g450_controls[i].
desc.id == 0x08000000) {
76 if (v4l2_id == g450_controls[i].
desc.id) {
85 return (
int*)((
char*)minfo + g450_controls[idx].
control);
93 *get_ctrl_ptr(minfo, i) = g450_controls[
i].
desc.default_value;
131 static void g450_compute_bwlevel(
const struct matrox_fb_info *minfo,
int *
bl,
134 const int b = minfo->
altout.tvo_params.brightness +
BLMIN;
135 const int c = minfo->
altout.tvo_params.contrast;
144 i = get_ctrl_id(p->
id);
146 *p = g450_controls[
i].
desc;
162 static int g450_set_ctrl(
void* md,
struct v4l2_control *p) {
166 i = get_ctrl_id(p->
id);
167 if (i < 0)
return -
EINVAL;
172 if (p->
value == *get_ctrl_ptr(minfo, i))
return 0;
183 *get_ctrl_ptr(minfo, i) = p->
value;
189 int blacklevel, whitelevel;
190 g450_compute_bwlevel(minfo, &blacklevel, &whitelevel);
191 cve2_set_reg10(minfo, 0x0e, blacklevel);
192 cve2_set_reg10(minfo, 0x1e, whitelevel);
196 cve2_set_reg(minfo, 0x20, p->
value);
197 cve2_set_reg(minfo, 0x22, p->
value);
200 cve2_set_reg(minfo, 0x25, p->
value);
204 unsigned char val = cve2_get_reg(minfo, 0x05);
205 if (p->
value) val |= 0x02;
207 cve2_set_reg(minfo, 0x05, val);
216 static int g450_get_ctrl(
void* md,
struct v4l2_control *p) {
220 i = get_ctrl_id(p->
id);
221 if (i < 0)
return -
EINVAL;
222 p->
value = *get_ctrl_ptr(minfo, i);
245 unsigned int pixclock;
246 unsigned long long piic;
250 r->
regs[0x80] = 0x03;
252 hvis = ((mt->
HDisplay << 1) + 3) & ~3;
258 piic = 1000000000ULL * hvis;
280 r->
regs[0] = piic >> 24;
281 r->
regs[1] = piic >> 16;
282 r->
regs[2] = piic >> 8;
283 r->
regs[3] = piic >> 0;
284 hbp = (((outd->
h_b_porch + pixclock) / pixclock)) & ~1;
285 hfp = (((outd->
h_f_porch + pixclock) / pixclock)) & ~1;
286 hsl = (((outd->
h_sync + pixclock) / pixclock)) & ~1;
287 hlen = hvis + hfp + hsl + hbp;
290 dprintk(
KERN_DEBUG "WL: vis=%u, hf=%u, hs=%u, hb=%u, total=%u\n", hvis, hfp, hsl, hbp, hlen);
296 }
else if (over < 10) {
307 r->
regs[0x09] = (outd->
burst + pixclock - 1) / pixclock;
310 r->
regs[0x31] = hvis / 8;
311 r->
regs[0x32] = hvis & 7;
313 dprintk(
KERN_DEBUG "PG: vis=%04X, hf=%02X, hs=%02X, hb=%02X, total=%04X\n", hvis, hfp, hsl, hbp, hlen);
332 unsigned int vsyncend;
333 unsigned int vdisplay;
338 if (vtotal < outd->v_total) {
339 unsigned int yovr = outd->
v_total - vtotal;
341 vsyncend += yovr >> 1;
342 }
else if (vtotal > outd->
v_total) {
346 upper = (outd->
v_total - vsyncend) >> 1;
349 r->
regs[0x33] = upper - 1;
350 r->
regs[0x82] = upper;
351 r->
regs[0x83] = upper >> 8;
363 .h_f_porch = 1407407,
365 .h_b_porch = 5777778,
366 .chromasc = 19042247534182ULL,
372 .h_f_porch = 1333333,
374 .h_b_porch = 4666667,
375 .chromasc = 15374030659475ULL,
380 static const struct mavenregs palregs = { {
381 0x2A, 0x09, 0x8A, 0xCB,
437 0x21, 0xF0, 0x7C, 0x1F,
502 #define LR(x) cve2_set_reg(minfo, (x), m->regs[(x)])
512 cve2_set_reg(minfo, 0x3E, 0x01);
514 for (i = 0; i < 0x3E; i++) {
517 cve2_set_reg(minfo, 0x3E, 0x00);
520 static int matroxfb_g450_compute(
void* md,
struct my_timming* mt) {
529 cve2_init_TVdata(minfo->
outputs[1].mode, &minfo->
hw.maven, &outd);
531 int blacklevel, whitelevel;
532 g450_compute_bwlevel(minfo, &blacklevel, &whitelevel);
533 minfo->
hw.maven.regs[0x0E] = blacklevel >> 2;
534 minfo->
hw.maven.regs[0x0F] = blacklevel & 3;
535 minfo->
hw.maven.regs[0x1E] = whitelevel >> 2;
536 minfo->
hw.maven.regs[0x1F] = whitelevel & 3;
538 minfo->
hw.maven.regs[0x20] =
539 minfo->
hw.maven.regs[0x22] = minfo->
altout.tvo_params.saturation;
541 minfo->
hw.maven.regs[0x25] = minfo->
altout.tvo_params.hue;
543 if (minfo->
altout.tvo_params.testout) {
544 minfo->
hw.maven.regs[0x05] |= 0x02;
547 computeRegs(minfo, &minfo->
hw.maven, mt, outd);
548 }
else if (mt->
mnp < 0) {
558 static int matroxfb_g450_program(
void* md) {
562 cve2_init_TV(minfo, &minfo->
hw.maven);
567 static int matroxfb_g450_verify_mode(
void* md,
u_int32_t arg) {
577 static int g450_dvi_compute(
void* md,
struct my_timming* mt) {
588 .name =
"Secondary output",
589 .compute = matroxfb_g450_compute,
590 .program = matroxfb_g450_program,
591 .verifymode = matroxfb_g450_verify_mode,
592 .getqueryctrl = g450_query_ctrl,
593 .getctrl = g450_get_ctrl,
594 .setctrl = g450_set_ctrl,
598 .name =
"DVI output",
599 .compute = g450_dvi_compute,
606 tvo_fill_defaults(minfo);
608 minfo->
outputs[1].data = minfo;
609 minfo->
outputs[1].output = &matroxfb_g450_altout;
612 minfo->
outputs[2].data = minfo;
613 minfo->
outputs[2].output = &matroxfb_g450_dvi;