matroxfb_g450.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  * Hardware accelerated Matrox Millennium I, II, Mystique, G100, G200, G400 and G450.
  4.  *
  5.  * (c) 1998-2001 Petr Vandrovec <vandrove@vc.cvut.cz>
  6.  *
  7.  * Portions Copyright (c) 2001 Matrox Graphics Inc.
  8.  *
  9.  * Version: 1.62 2001/11/29
  10.  *
  11.  * See matroxfb_base.c for contributors.
  12.  *
  13.  */
  14. #include "matroxfb_g450.h"
  15. #include "matroxfb_misc.h"
  16. #include "matroxfb_DAC1064.h"
  17. #include "g450_pll.h"
  18. #include <linux/matroxfb.h>
  19. #include <asm/uaccess.h>
  20. static int matroxfb_g450_compute(void* md, struct my_timming* mt) {
  21. #define m2info ((struct matroxfb_g450_info*)md)
  22. #define minfo (m2info->primary_dev)
  23. ACCESS_FBINFO(hw).vidclk = mt->pixclock;
  24. #undef minfo
  25. #undef m2info
  26. return 0;
  27. }
  28. static int matroxfb_g450_program(void* md) {
  29. #define m2info ((struct matroxfb_g450_info*)md)
  30. #define minfo (m2info->primary_dev)
  31. matroxfb_g450_setclk(PMINFO ACCESS_FBINFO(hw).vidclk, M_VIDEO_PLL);
  32. #undef minfo
  33. #undef m2info
  34. return 0;
  35. }
  36. static int matroxfb_g450_start(void* md) {
  37. return 0;
  38. }
  39. static void matroxfb_g450_incuse(void* md) {
  40. MOD_INC_USE_COUNT;
  41. }
  42. static void matroxfb_g450_decuse(void* md) {
  43. MOD_DEC_USE_COUNT;
  44. }
  45. static int matroxfb_g450_set_mode(void* md, u_int32_t arg) {
  46. if (arg == MATROXFB_OUTPUT_MODE_MONITOR) {
  47. return 1;
  48. }
  49. return -EINVAL;
  50. }
  51. static int matroxfb_g450_get_mode(void* md, u_int32_t* arg) {
  52. *arg = MATROXFB_OUTPUT_MODE_MONITOR;
  53. return 0;
  54. }
  55. static struct matrox_altout matroxfb_g450_altout = {
  56. matroxfb_g450_compute,
  57. matroxfb_g450_program,
  58. matroxfb_g450_start,
  59. matroxfb_g450_incuse,
  60. matroxfb_g450_decuse,
  61. matroxfb_g450_set_mode,
  62. matroxfb_g450_get_mode
  63. };
  64. static int matroxfb_g450_connect(struct matroxfb_g450_info* m2info) {
  65. MINFO_FROM(m2info->primary_dev);
  66. down_write(&ACCESS_FBINFO(altout.lock));
  67. ACCESS_FBINFO(altout.device) = m2info;
  68. ACCESS_FBINFO(altout.output) = &matroxfb_g450_altout;
  69. up_write(&ACCESS_FBINFO(altout.lock));
  70. ACCESS_FBINFO(output.all) |= MATROXFB_OUTPUT_CONN_SECONDARY;
  71. matroxfb_switch(ACCESS_FBINFO(currcon), (struct fb_info*)MINFO);
  72. return 0;
  73. }
  74. static void matroxfb_g450_shutdown(struct matroxfb_g450_info* m2info) {
  75. MINFO_FROM(m2info->primary_dev);
  76. if (MINFO) {
  77. ACCESS_FBINFO(output.all) &= ~MATROXFB_OUTPUT_CONN_SECONDARY;
  78. ACCESS_FBINFO(output.ph) &= ~MATROXFB_OUTPUT_CONN_SECONDARY;
  79. ACCESS_FBINFO(output.sh) &= ~MATROXFB_OUTPUT_CONN_SECONDARY;
  80. down_write(&ACCESS_FBINFO(altout.lock));
  81. ACCESS_FBINFO(altout.device) = NULL;
  82. ACCESS_FBINFO(altout.output) = NULL;
  83. up_write(&ACCESS_FBINFO(altout.lock));
  84. m2info->primary_dev = NULL;
  85. }
  86. }
  87. /* we do not have __setup() yet */
  88. static void* matroxfb_g450_probe(struct matrox_fb_info* minfo) {
  89. struct matroxfb_g450_info* m2info;
  90. /* hardware is not G450... */
  91. if (!ACCESS_FBINFO(devflags.g450dac))
  92. return NULL;
  93. m2info = (struct matroxfb_g450_info*)kmalloc(sizeof(*m2info), GFP_KERNEL);
  94. if (!m2info) {
  95. printk(KERN_ERR "matroxfb_g450: Not enough memory for G450 DAC control structsn");
  96. return NULL;
  97. }
  98. memset(m2info, 0, sizeof(*m2info));
  99. m2info->primary_dev = MINFO;
  100. if (matroxfb_g450_connect(m2info)) {
  101. kfree(m2info);
  102. printk(KERN_ERR "matroxfb_g450: G450 DAC failed to initializen");
  103. return NULL;
  104. }
  105. return m2info;
  106. }
  107. static void matroxfb_g450_remove(struct matrox_fb_info* minfo, void* g450) {
  108. matroxfb_g450_shutdown(g450);
  109. kfree(g450);
  110. }
  111. static struct matroxfb_driver g450 = {
  112. name: "Matrox G450 output #2",
  113. probe: matroxfb_g450_probe,
  114. remove: matroxfb_g450_remove };
  115. static int matroxfb_g450_init(void) {
  116. matroxfb_register_driver(&g450);
  117. return 0;
  118. }
  119. static void matroxfb_g450_exit(void) {
  120. matroxfb_unregister_driver(&g450);
  121. }
  122. MODULE_AUTHOR("(c) 2000-2001 Petr Vandrovec <vandrove@vc.cvut.cz>");
  123. MODULE_DESCRIPTION("Matrox G450 secondary output driver");
  124. MODULE_LICENSE("GPL");
  125. module_init(matroxfb_g450_init);
  126. module_exit(matroxfb_g450_exit);