matroxfb_g450.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200, G400 and G450.
  5. *
  6. * (c) 1998-2002 Petr Vandrovec <vandrove@vc.cvut.cz>
  7. *
  8. * Portions Copyright (c) 2001 Matrox Graphics Inc.
  9. *
  10. * Version: 1.65 2002/08/14
  11. *
  12. * See matroxfb_base.c for contributors.
  13. *
  14. */
  15. #include <linux/export.h>
  16. #include "matroxfb_base.h"
  17. #include "matroxfb_misc.h"
  18. #include "matroxfb_DAC1064.h"
  19. #include "g450_pll.h"
  20. #include <linux/matroxfb.h>
  21. #include <asm/div64.h>
  22. #include "matroxfb_g450.h"
  23. /* Definition of the various controls */
  24. struct mctl {
  25. struct v4l2_queryctrl desc;
  26. size_t control;
  27. };
  28. #define BLMIN 0xF3
  29. #define WLMAX 0x3FF
  30. static const struct mctl g450_controls[] =
  31. { { { V4L2_CID_BRIGHTNESS, V4L2_CTRL_TYPE_INTEGER,
  32. "brightness",
  33. 0, WLMAX-BLMIN, 1, 370-BLMIN,
  34. 0,
  35. }, offsetof(struct matrox_fb_info, altout.tvo_params.brightness) },
  36. { { V4L2_CID_CONTRAST, V4L2_CTRL_TYPE_INTEGER,
  37. "contrast",
  38. 0, 1023, 1, 127,
  39. 0,
  40. }, offsetof(struct matrox_fb_info, altout.tvo_params.contrast) },
  41. { { V4L2_CID_SATURATION, V4L2_CTRL_TYPE_INTEGER,
  42. "saturation",
  43. 0, 255, 1, 165,
  44. 0,
  45. }, offsetof(struct matrox_fb_info, altout.tvo_params.saturation) },
  46. { { V4L2_CID_HUE, V4L2_CTRL_TYPE_INTEGER,
  47. "hue",
  48. 0, 255, 1, 0,
  49. 0,
  50. }, offsetof(struct matrox_fb_info, altout.tvo_params.hue) },
  51. { { MATROXFB_CID_TESTOUT, V4L2_CTRL_TYPE_BOOLEAN,
  52. "test output",
  53. 0, 1, 1, 0,
  54. 0,
  55. }, offsetof(struct matrox_fb_info, altout.tvo_params.testout) },
  56. };
  57. #define G450CTRLS ARRAY_SIZE(g450_controls)
  58. /* Return: positive number: id found
  59. -EINVAL: id not found, return failure
  60. -ENOENT: id not found, create fake disabled control */
  61. static int get_ctrl_id(__u32 v4l2_id) {
  62. int i;
  63. for (i = 0; i < G450CTRLS; i++) {
  64. if (v4l2_id < g450_controls[i].desc.id) {
  65. if (g450_controls[i].desc.id == 0x08000000) {
  66. return -EINVAL;
  67. }
  68. return -ENOENT;
  69. }
  70. if (v4l2_id == g450_controls[i].desc.id) {
  71. return i;
  72. }
  73. }
  74. return -EINVAL;
  75. }
  76. static inline int *get_ctrl_ptr(struct matrox_fb_info *minfo, unsigned int idx)
  77. {
  78. return (int*)((char*)minfo + g450_controls[idx].control);
  79. }
  80. static void tvo_fill_defaults(struct matrox_fb_info *minfo)
  81. {
  82. unsigned int i;
  83. for (i = 0; i < G450CTRLS; i++) {
  84. *get_ctrl_ptr(minfo, i) = g450_controls[i].desc.default_value;
  85. }
  86. }
  87. static int cve2_get_reg(struct matrox_fb_info *minfo, int reg)
  88. {
  89. unsigned long flags;
  90. int val;
  91. matroxfb_DAC_lock_irqsave(flags);
  92. matroxfb_DAC_out(minfo, 0x87, reg);
  93. val = matroxfb_DAC_in(minfo, 0x88);
  94. matroxfb_DAC_unlock_irqrestore(flags);
  95. return val;
  96. }
  97. static void cve2_set_reg(struct matrox_fb_info *minfo, int reg, int val)
  98. {
  99. unsigned long flags;
  100. matroxfb_DAC_lock_irqsave(flags);
  101. matroxfb_DAC_out(minfo, 0x87, reg);
  102. matroxfb_DAC_out(minfo, 0x88, val);
  103. matroxfb_DAC_unlock_irqrestore(flags);
  104. }
  105. static void cve2_set_reg10(struct matrox_fb_info *minfo, int reg, int val)
  106. {
  107. unsigned long flags;
  108. matroxfb_DAC_lock_irqsave(flags);
  109. matroxfb_DAC_out(minfo, 0x87, reg);
  110. matroxfb_DAC_out(minfo, 0x88, val >> 2);
  111. matroxfb_DAC_out(minfo, 0x87, reg + 1);
  112. matroxfb_DAC_out(minfo, 0x88, val & 3);
  113. matroxfb_DAC_unlock_irqrestore(flags);
  114. }
  115. static void g450_compute_bwlevel(const struct matrox_fb_info *minfo, int *bl,
  116. int *wl)
  117. {
  118. const int b = minfo->altout.tvo_params.brightness + BLMIN;
  119. const int c = minfo->altout.tvo_params.contrast;
  120. *bl = max(b - c, BLMIN);
  121. *wl = min(b + c, WLMAX);
  122. }
  123. static int g450_query_ctrl(void* md, struct v4l2_queryctrl *p) {
  124. int i;
  125. i = get_ctrl_id(p->id);
  126. if (i >= 0) {
  127. *p = g450_controls[i].desc;
  128. return 0;
  129. }
  130. if (i == -ENOENT) {
  131. static const struct v4l2_queryctrl disctrl =
  132. { .flags = V4L2_CTRL_FLAG_DISABLED };
  133. i = p->id;
  134. *p = disctrl;
  135. p->id = i;
  136. sprintf(p->name, "Ctrl #%08X", i);
  137. return 0;
  138. }
  139. return -EINVAL;
  140. }
  141. static int g450_set_ctrl(void* md, struct v4l2_control *p) {
  142. int i;
  143. struct matrox_fb_info *minfo = md;
  144. i = get_ctrl_id(p->id);
  145. if (i < 0) return -EINVAL;
  146. /*
  147. * Check if changed.
  148. */
  149. if (p->value == *get_ctrl_ptr(minfo, i)) return 0;
  150. /*
  151. * Check limits.
  152. */
  153. if (p->value > g450_controls[i].desc.maximum) return -EINVAL;
  154. if (p->value < g450_controls[i].desc.minimum) return -EINVAL;
  155. /*
  156. * Store new value.
  157. */
  158. *get_ctrl_ptr(minfo, i) = p->value;
  159. switch (p->id) {
  160. case V4L2_CID_BRIGHTNESS:
  161. case V4L2_CID_CONTRAST:
  162. {
  163. int blacklevel, whitelevel;
  164. g450_compute_bwlevel(minfo, &blacklevel, &whitelevel);
  165. cve2_set_reg10(minfo, 0x0e, blacklevel);
  166. cve2_set_reg10(minfo, 0x1e, whitelevel);
  167. }
  168. break;
  169. case V4L2_CID_SATURATION:
  170. cve2_set_reg(minfo, 0x20, p->value);
  171. cve2_set_reg(minfo, 0x22, p->value);
  172. break;
  173. case V4L2_CID_HUE:
  174. cve2_set_reg(minfo, 0x25, p->value);
  175. break;
  176. case MATROXFB_CID_TESTOUT:
  177. {
  178. unsigned char val = cve2_get_reg(minfo, 0x05);
  179. if (p->value) val |= 0x02;
  180. else val &= ~0x02;
  181. cve2_set_reg(minfo, 0x05, val);
  182. }
  183. break;
  184. }
  185. return 0;
  186. }
  187. static int g450_get_ctrl(void* md, struct v4l2_control *p) {
  188. int i;
  189. struct matrox_fb_info *minfo = md;
  190. i = get_ctrl_id(p->id);
  191. if (i < 0) return -EINVAL;
  192. p->value = *get_ctrl_ptr(minfo, i);
  193. return 0;
  194. }
  195. struct output_desc {
  196. unsigned int h_vis;
  197. unsigned int h_f_porch;
  198. unsigned int h_sync;
  199. unsigned int h_b_porch;
  200. unsigned long long int chromasc;
  201. unsigned int burst;
  202. unsigned int v_total;
  203. };
  204. static void computeRegs(struct matrox_fb_info *minfo, struct mavenregs *r,
  205. struct my_timming *mt, const struct output_desc *outd)
  206. {
  207. u_int32_t chromasc;
  208. u_int32_t hlen;
  209. u_int32_t hsl;
  210. u_int32_t hbp;
  211. u_int32_t hfp;
  212. u_int32_t hvis;
  213. unsigned int pixclock;
  214. unsigned long long piic;
  215. int mnp;
  216. int over;
  217. r->regs[0x80] = 0x03; /* | 0x40 for SCART */
  218. hvis = ((mt->HDisplay << 1) + 3) & ~3;
  219. if (hvis >= 2048) {
  220. hvis = 2044;
  221. }
  222. piic = 1000000000ULL * hvis;
  223. do_div(piic, outd->h_vis);
  224. dprintk(KERN_DEBUG "Want %u kHz pixclock\n", (unsigned int)piic);
  225. mnp = matroxfb_g450_setclk(minfo, piic, M_VIDEO_PLL);
  226. mt->mnp = mnp;
  227. mt->pixclock = g450_mnp2f(minfo, mnp);
  228. dprintk(KERN_DEBUG "MNP=%08X\n", mnp);
  229. pixclock = 1000000000U / mt->pixclock;
  230. dprintk(KERN_DEBUG "Got %u ps pixclock\n", pixclock);
  231. piic = outd->chromasc;
  232. do_div(piic, mt->pixclock);
  233. chromasc = piic;
  234. dprintk(KERN_DEBUG "Chroma is %08X\n", chromasc);
  235. r->regs[0] = piic >> 24;
  236. r->regs[1] = piic >> 16;
  237. r->regs[2] = piic >> 8;
  238. r->regs[3] = piic >> 0;
  239. hbp = (((outd->h_b_porch + pixclock) / pixclock)) & ~1;
  240. hfp = (((outd->h_f_porch + pixclock) / pixclock)) & ~1;
  241. hsl = (((outd->h_sync + pixclock) / pixclock)) & ~1;
  242. hlen = hvis + hfp + hsl + hbp;
  243. over = hlen & 0x0F;
  244. dprintk(KERN_DEBUG "WL: vis=%u, hf=%u, hs=%u, hb=%u, total=%u\n", hvis, hfp, hsl, hbp, hlen);
  245. if (over) {
  246. hfp -= over;
  247. hlen -= over;
  248. if (over <= 2) {
  249. } else if (over < 10) {
  250. hfp += 4;
  251. hlen += 4;
  252. } else {
  253. hfp += 16;
  254. hlen += 16;
  255. }
  256. }
  257. /* maybe cve2 has requirement 800 < hlen < 1184 */
  258. r->regs[0x08] = hsl;
  259. r->regs[0x09] = (outd->burst + pixclock - 1) / pixclock; /* burst length */
  260. r->regs[0x0A] = hbp;
  261. r->regs[0x2C] = hfp;
  262. r->regs[0x31] = hvis / 8;
  263. r->regs[0x32] = hvis & 7;
  264. dprintk(KERN_DEBUG "PG: vis=%04X, hf=%02X, hs=%02X, hb=%02X, total=%04X\n", hvis, hfp, hsl, hbp, hlen);
  265. r->regs[0x84] = 1; /* x sync point */
  266. r->regs[0x85] = 0;
  267. hvis = hvis >> 1;
  268. hlen = hlen >> 1;
  269. dprintk(KERN_DEBUG "hlen=%u hvis=%u\n", hlen, hvis);
  270. mt->interlaced = 1;
  271. mt->HDisplay = hvis & ~7;
  272. mt->HSyncStart = mt->HDisplay + 8;
  273. mt->HSyncEnd = (hlen & ~7) - 8;
  274. mt->HTotal = hlen;
  275. {
  276. int upper;
  277. unsigned int vtotal;
  278. unsigned int vsyncend;
  279. unsigned int vdisplay;
  280. vtotal = mt->VTotal;
  281. vsyncend = mt->VSyncEnd;
  282. vdisplay = mt->VDisplay;
  283. if (vtotal < outd->v_total) {
  284. unsigned int yovr = outd->v_total - vtotal;
  285. vsyncend += yovr >> 1;
  286. } else if (vtotal > outd->v_total) {
  287. vdisplay = outd->v_total - 4;
  288. vsyncend = outd->v_total;
  289. }
  290. upper = (outd->v_total - vsyncend) >> 1; /* in field lines */
  291. r->regs[0x17] = outd->v_total / 4;
  292. r->regs[0x18] = outd->v_total & 3;
  293. r->regs[0x33] = upper - 1; /* upper blanking */
  294. r->regs[0x82] = upper; /* y sync point */
  295. r->regs[0x83] = upper >> 8;
  296. mt->VDisplay = vdisplay;
  297. mt->VSyncStart = outd->v_total - 2;
  298. mt->VSyncEnd = outd->v_total;
  299. mt->VTotal = outd->v_total;
  300. }
  301. }
  302. static void cve2_init_TVdata(int norm, struct mavenregs* data, const struct output_desc** outd) {
  303. static const struct output_desc paloutd = {
  304. .h_vis = 52148148, // ps
  305. .h_f_porch = 1407407, // ps
  306. .h_sync = 4666667, // ps
  307. .h_b_porch = 5777778, // ps
  308. .chromasc = 19042247534182ULL, // 4433618.750 Hz
  309. .burst = 2518518, // ps
  310. .v_total = 625,
  311. };
  312. static const struct output_desc ntscoutd = {
  313. .h_vis = 52888889, // ps
  314. .h_f_porch = 1333333, // ps
  315. .h_sync = 4666667, // ps
  316. .h_b_porch = 4666667, // ps
  317. .chromasc = 15374030659475ULL, // 3579545.454 Hz
  318. .burst = 2418418, // ps
  319. .v_total = 525, // lines
  320. };
  321. static const struct mavenregs palregs = { {
  322. 0x2A, 0x09, 0x8A, 0xCB, /* 00: chroma subcarrier */
  323. 0x00,
  324. 0x00, /* test */
  325. 0xF9, /* modified by code (F9 written...) */
  326. 0x00, /* ? not written */
  327. 0x7E, /* 08 */
  328. 0x44, /* 09 */
  329. 0x9C, /* 0A */
  330. 0x2E, /* 0B */
  331. 0x21, /* 0C */
  332. 0x00, /* ? not written */
  333. // 0x3F, 0x03, /* 0E-0F */
  334. 0x3C, 0x03,
  335. 0x3C, 0x03, /* 10-11 */
  336. 0x1A, /* 12 */
  337. 0x2A, /* 13 */
  338. 0x1C, 0x3D, 0x14, /* 14-16 */
  339. 0x9C, 0x01, /* 17-18 */
  340. 0x00, /* 19 */
  341. 0xFE, /* 1A */
  342. 0x7E, /* 1B */
  343. 0x60, /* 1C */
  344. 0x05, /* 1D */
  345. // 0x89, 0x03, /* 1E-1F */
  346. 0xAD, 0x03,
  347. // 0x72, /* 20 */
  348. 0xA5,
  349. 0x07, /* 21 */
  350. // 0x72, /* 22 */
  351. 0xA5,
  352. 0x00, /* 23 */
  353. 0x00, /* 24 */
  354. 0x00, /* 25 */
  355. 0x08, /* 26 */
  356. 0x04, /* 27 */
  357. 0x00, /* 28 */
  358. 0x1A, /* 29 */
  359. 0x55, 0x01, /* 2A-2B */
  360. 0x26, /* 2C */
  361. 0x07, 0x7E, /* 2D-2E */
  362. 0x02, 0x54, /* 2F-30 */
  363. 0xB0, 0x00, /* 31-32 */
  364. 0x14, /* 33 */
  365. 0x49, /* 34 */
  366. 0x00, /* 35 written multiple times */
  367. 0x00, /* 36 not written */
  368. 0xA3, /* 37 */
  369. 0xC8, /* 38 */
  370. 0x22, /* 39 */
  371. 0x02, /* 3A */
  372. 0x22, /* 3B */
  373. 0x3F, 0x03, /* 3C-3D */
  374. 0x00, /* 3E written multiple times */
  375. 0x00, /* 3F not written */
  376. } };
  377. static const struct mavenregs ntscregs = { {
  378. 0x21, 0xF0, 0x7C, 0x1F, /* 00: chroma subcarrier */
  379. 0x00,
  380. 0x00, /* test */
  381. 0xF9, /* modified by code (F9 written...) */
  382. 0x00, /* ? not written */
  383. 0x7E, /* 08 */
  384. 0x43, /* 09 */
  385. 0x7E, /* 0A */
  386. 0x3D, /* 0B */
  387. 0x00, /* 0C */
  388. 0x00, /* ? not written */
  389. 0x41, 0x00, /* 0E-0F */
  390. 0x3C, 0x00, /* 10-11 */
  391. 0x17, /* 12 */
  392. 0x21, /* 13 */
  393. 0x1B, 0x1B, 0x24, /* 14-16 */
  394. 0x83, 0x01, /* 17-18 */
  395. 0x00, /* 19 */
  396. 0x0F, /* 1A */
  397. 0x0F, /* 1B */
  398. 0x60, /* 1C */
  399. 0x05, /* 1D */
  400. //0x89, 0x02, /* 1E-1F */
  401. 0xC0, 0x02, /* 1E-1F */
  402. //0x5F, /* 20 */
  403. 0x9C, /* 20 */
  404. 0x04, /* 21 */
  405. //0x5F, /* 22 */
  406. 0x9C, /* 22 */
  407. 0x01, /* 23 */
  408. 0x02, /* 24 */
  409. 0x00, /* 25 */
  410. 0x0A, /* 26 */
  411. 0x05, /* 27 */
  412. 0x00, /* 28 */
  413. 0x10, /* 29 */
  414. 0xFF, 0x03, /* 2A-2B */
  415. 0x24, /* 2C */
  416. 0x0F, 0x78, /* 2D-2E */
  417. 0x00, 0x00, /* 2F-30 */
  418. 0xB2, 0x04, /* 31-32 */
  419. 0x14, /* 33 */
  420. 0x02, /* 34 */
  421. 0x00, /* 35 written multiple times */
  422. 0x00, /* 36 not written */
  423. 0xA3, /* 37 */
  424. 0xC8, /* 38 */
  425. 0x15, /* 39 */
  426. 0x05, /* 3A */
  427. 0x3B, /* 3B */
  428. 0x3C, 0x00, /* 3C-3D */
  429. 0x00, /* 3E written multiple times */
  430. 0x00, /* never written */
  431. } };
  432. if (norm == MATROXFB_OUTPUT_MODE_PAL) {
  433. *data = palregs;
  434. *outd = &paloutd;
  435. } else {
  436. *data = ntscregs;
  437. *outd = &ntscoutd;
  438. }
  439. return;
  440. }
  441. #define LR(x) cve2_set_reg(minfo, (x), m->regs[(x)])
  442. static void cve2_init_TV(struct matrox_fb_info *minfo,
  443. const struct mavenregs *m)
  444. {
  445. int i;
  446. LR(0x80);
  447. LR(0x82); LR(0x83);
  448. LR(0x84); LR(0x85);
  449. cve2_set_reg(minfo, 0x3E, 0x01);
  450. for (i = 0; i < 0x3E; i++) {
  451. LR(i);
  452. }
  453. cve2_set_reg(minfo, 0x3E, 0x00);
  454. }
  455. static int matroxfb_g450_compute(void* md, struct my_timming* mt) {
  456. struct matrox_fb_info *minfo = md;
  457. dprintk(KERN_DEBUG "Computing, mode=%u\n", minfo->outputs[1].mode);
  458. if (mt->crtc == MATROXFB_SRC_CRTC2 &&
  459. minfo->outputs[1].mode != MATROXFB_OUTPUT_MODE_MONITOR) {
  460. const struct output_desc* outd;
  461. cve2_init_TVdata(minfo->outputs[1].mode, &minfo->hw.maven, &outd);
  462. {
  463. int blacklevel, whitelevel;
  464. g450_compute_bwlevel(minfo, &blacklevel, &whitelevel);
  465. minfo->hw.maven.regs[0x0E] = blacklevel >> 2;
  466. minfo->hw.maven.regs[0x0F] = blacklevel & 3;
  467. minfo->hw.maven.regs[0x1E] = whitelevel >> 2;
  468. minfo->hw.maven.regs[0x1F] = whitelevel & 3;
  469. minfo->hw.maven.regs[0x20] =
  470. minfo->hw.maven.regs[0x22] = minfo->altout.tvo_params.saturation;
  471. minfo->hw.maven.regs[0x25] = minfo->altout.tvo_params.hue;
  472. if (minfo->altout.tvo_params.testout) {
  473. minfo->hw.maven.regs[0x05] |= 0x02;
  474. }
  475. }
  476. computeRegs(minfo, &minfo->hw.maven, mt, outd);
  477. } else if (mt->mnp < 0) {
  478. /* We must program clocks before CRTC2, otherwise interlaced mode
  479. startup may fail */
  480. mt->mnp = matroxfb_g450_setclk(minfo, mt->pixclock, (mt->crtc == MATROXFB_SRC_CRTC1) ? M_PIXEL_PLL_C : M_VIDEO_PLL);
  481. mt->pixclock = g450_mnp2f(minfo, mt->mnp);
  482. }
  483. dprintk(KERN_DEBUG "Pixclock = %u\n", mt->pixclock);
  484. return 0;
  485. }
  486. static int matroxfb_g450_program(void* md) {
  487. struct matrox_fb_info *minfo = md;
  488. if (minfo->outputs[1].mode != MATROXFB_OUTPUT_MODE_MONITOR) {
  489. cve2_init_TV(minfo, &minfo->hw.maven);
  490. }
  491. return 0;
  492. }
  493. static int matroxfb_g450_verify_mode(void* md, u_int32_t arg) {
  494. switch (arg) {
  495. case MATROXFB_OUTPUT_MODE_PAL:
  496. case MATROXFB_OUTPUT_MODE_NTSC:
  497. case MATROXFB_OUTPUT_MODE_MONITOR:
  498. return 0;
  499. }
  500. return -EINVAL;
  501. }
  502. static int g450_dvi_compute(void* md, struct my_timming* mt) {
  503. struct matrox_fb_info *minfo = md;
  504. if (mt->mnp < 0) {
  505. mt->mnp = matroxfb_g450_setclk(minfo, mt->pixclock, (mt->crtc == MATROXFB_SRC_CRTC1) ? M_PIXEL_PLL_C : M_VIDEO_PLL);
  506. mt->pixclock = g450_mnp2f(minfo, mt->mnp);
  507. }
  508. return 0;
  509. }
  510. static struct matrox_altout matroxfb_g450_altout = {
  511. .name = "Secondary output",
  512. .compute = matroxfb_g450_compute,
  513. .program = matroxfb_g450_program,
  514. .verifymode = matroxfb_g450_verify_mode,
  515. .getqueryctrl = g450_query_ctrl,
  516. .getctrl = g450_get_ctrl,
  517. .setctrl = g450_set_ctrl,
  518. };
  519. static struct matrox_altout matroxfb_g450_dvi = {
  520. .name = "DVI output",
  521. .compute = g450_dvi_compute,
  522. };
  523. void matroxfb_g450_connect(struct matrox_fb_info *minfo)
  524. {
  525. if (minfo->devflags.g450dac) {
  526. down_write(&minfo->altout.lock);
  527. tvo_fill_defaults(minfo);
  528. minfo->outputs[1].src = minfo->outputs[1].default_src;
  529. minfo->outputs[1].data = minfo;
  530. minfo->outputs[1].output = &matroxfb_g450_altout;
  531. minfo->outputs[1].mode = MATROXFB_OUTPUT_MODE_MONITOR;
  532. minfo->outputs[2].src = minfo->outputs[2].default_src;
  533. minfo->outputs[2].data = minfo;
  534. minfo->outputs[2].output = &matroxfb_g450_dvi;
  535. minfo->outputs[2].mode = MATROXFB_OUTPUT_MODE_MONITOR;
  536. up_write(&minfo->altout.lock);
  537. }
  538. }
  539. void matroxfb_g450_shutdown(struct matrox_fb_info *minfo)
  540. {
  541. if (minfo->devflags.g450dac) {
  542. down_write(&minfo->altout.lock);
  543. minfo->outputs[1].src = MATROXFB_SRC_NONE;
  544. minfo->outputs[1].output = NULL;
  545. minfo->outputs[1].data = NULL;
  546. minfo->outputs[1].mode = MATROXFB_OUTPUT_MODE_MONITOR;
  547. minfo->outputs[2].src = MATROXFB_SRC_NONE;
  548. minfo->outputs[2].output = NULL;
  549. minfo->outputs[2].data = NULL;
  550. minfo->outputs[2].mode = MATROXFB_OUTPUT_MODE_MONITOR;
  551. up_write(&minfo->altout.lock);
  552. }
  553. }
  554. EXPORT_SYMBOL(matroxfb_g450_connect);
  555. EXPORT_SYMBOL(matroxfb_g450_shutdown);
  556. MODULE_AUTHOR("(c) 2000-2002 Petr Vandrovec <vandrove@vc.cvut.cz>");
  557. MODULE_DESCRIPTION("Matrox G450/G550 output driver");
  558. MODULE_LICENSE("GPL");