matroxfb_g450.c 15 KB

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