radeon_legacy_encoders.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. /*
  2. * Copyright 2007-8 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. * OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors: Dave Airlie
  24. * Alex Deucher
  25. */
  26. #include "drmP.h"
  27. #include "drm_crtc_helper.h"
  28. #include "radeon_drm.h"
  29. #include "radeon.h"
  30. #include "atom.h"
  31. static void radeon_legacy_encoder_disable(struct drm_encoder *encoder)
  32. {
  33. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  34. struct drm_encoder_helper_funcs *encoder_funcs;
  35. encoder_funcs = encoder->helper_private;
  36. encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF);
  37. radeon_encoder->active_device = 0;
  38. }
  39. static void radeon_legacy_lvds_dpms(struct drm_encoder *encoder, int mode)
  40. {
  41. struct drm_device *dev = encoder->dev;
  42. struct radeon_device *rdev = dev->dev_private;
  43. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  44. uint32_t lvds_gen_cntl, lvds_pll_cntl, pixclks_cntl, disp_pwr_man;
  45. int panel_pwr_delay = 2000;
  46. DRM_DEBUG("\n");
  47. if (radeon_encoder->enc_priv) {
  48. if (rdev->is_atom_bios) {
  49. struct radeon_encoder_atom_dig *lvds = radeon_encoder->enc_priv;
  50. panel_pwr_delay = lvds->panel_pwr_delay;
  51. } else {
  52. struct radeon_encoder_lvds *lvds = radeon_encoder->enc_priv;
  53. panel_pwr_delay = lvds->panel_pwr_delay;
  54. }
  55. }
  56. switch (mode) {
  57. case DRM_MODE_DPMS_ON:
  58. disp_pwr_man = RREG32(RADEON_DISP_PWR_MAN);
  59. disp_pwr_man |= RADEON_AUTO_PWRUP_EN;
  60. WREG32(RADEON_DISP_PWR_MAN, disp_pwr_man);
  61. lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
  62. lvds_pll_cntl |= RADEON_LVDS_PLL_EN;
  63. WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl);
  64. udelay(1000);
  65. lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
  66. lvds_pll_cntl &= ~RADEON_LVDS_PLL_RESET;
  67. WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl);
  68. lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  69. lvds_gen_cntl |= (RADEON_LVDS_ON | RADEON_LVDS_EN | RADEON_LVDS_DIGON | RADEON_LVDS_BLON);
  70. lvds_gen_cntl &= ~(RADEON_LVDS_DISPLAY_DIS);
  71. udelay(panel_pwr_delay * 1000);
  72. WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
  73. break;
  74. case DRM_MODE_DPMS_STANDBY:
  75. case DRM_MODE_DPMS_SUSPEND:
  76. case DRM_MODE_DPMS_OFF:
  77. pixclks_cntl = RREG32_PLL(RADEON_PIXCLKS_CNTL);
  78. WREG32_PLL_P(RADEON_PIXCLKS_CNTL, 0, ~RADEON_PIXCLK_LVDS_ALWAYS_ONb);
  79. lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  80. lvds_gen_cntl |= RADEON_LVDS_DISPLAY_DIS;
  81. lvds_gen_cntl &= ~(RADEON_LVDS_ON | RADEON_LVDS_BLON | RADEON_LVDS_EN | RADEON_LVDS_DIGON);
  82. udelay(panel_pwr_delay * 1000);
  83. WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
  84. WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
  85. break;
  86. }
  87. if (rdev->is_atom_bios)
  88. radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  89. else
  90. radeon_combios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  91. }
  92. static void radeon_legacy_lvds_prepare(struct drm_encoder *encoder)
  93. {
  94. struct radeon_device *rdev = encoder->dev->dev_private;
  95. if (rdev->is_atom_bios)
  96. radeon_atom_output_lock(encoder, true);
  97. else
  98. radeon_combios_output_lock(encoder, true);
  99. radeon_legacy_lvds_dpms(encoder, DRM_MODE_DPMS_OFF);
  100. radeon_encoder_set_active_device(encoder);
  101. }
  102. static void radeon_legacy_lvds_commit(struct drm_encoder *encoder)
  103. {
  104. struct radeon_device *rdev = encoder->dev->dev_private;
  105. radeon_legacy_lvds_dpms(encoder, DRM_MODE_DPMS_ON);
  106. if (rdev->is_atom_bios)
  107. radeon_atom_output_lock(encoder, false);
  108. else
  109. radeon_combios_output_lock(encoder, false);
  110. }
  111. static void radeon_legacy_lvds_mode_set(struct drm_encoder *encoder,
  112. struct drm_display_mode *mode,
  113. struct drm_display_mode *adjusted_mode)
  114. {
  115. struct drm_device *dev = encoder->dev;
  116. struct radeon_device *rdev = dev->dev_private;
  117. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  118. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  119. uint32_t lvds_pll_cntl, lvds_gen_cntl, lvds_ss_gen_cntl;
  120. DRM_DEBUG("\n");
  121. lvds_pll_cntl = RREG32(RADEON_LVDS_PLL_CNTL);
  122. lvds_pll_cntl &= ~RADEON_LVDS_PLL_EN;
  123. lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
  124. if ((!rdev->is_atom_bios)) {
  125. struct radeon_encoder_lvds *lvds = (struct radeon_encoder_lvds *)radeon_encoder->enc_priv;
  126. if (lvds) {
  127. DRM_DEBUG("bios LVDS_GEN_CNTL: 0x%x\n", lvds->lvds_gen_cntl);
  128. lvds_gen_cntl = lvds->lvds_gen_cntl;
  129. lvds_ss_gen_cntl &= ~((0xf << RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) |
  130. (0xf << RADEON_LVDS_PWRSEQ_DELAY2_SHIFT));
  131. lvds_ss_gen_cntl |= ((lvds->panel_digon_delay << RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) |
  132. (lvds->panel_blon_delay << RADEON_LVDS_PWRSEQ_DELAY2_SHIFT));
  133. } else
  134. lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  135. } else
  136. lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
  137. lvds_gen_cntl |= RADEON_LVDS_DISPLAY_DIS;
  138. lvds_gen_cntl &= ~(RADEON_LVDS_ON |
  139. RADEON_LVDS_BLON |
  140. RADEON_LVDS_EN |
  141. RADEON_LVDS_RST_FM);
  142. if (ASIC_IS_R300(rdev))
  143. lvds_pll_cntl &= ~(R300_LVDS_SRC_SEL_MASK);
  144. if (radeon_crtc->crtc_id == 0) {
  145. if (ASIC_IS_R300(rdev)) {
  146. if (radeon_encoder->rmx_type != RMX_OFF)
  147. lvds_pll_cntl |= R300_LVDS_SRC_SEL_RMX;
  148. } else
  149. lvds_gen_cntl &= ~RADEON_LVDS_SEL_CRTC2;
  150. } else {
  151. if (ASIC_IS_R300(rdev))
  152. lvds_pll_cntl |= R300_LVDS_SRC_SEL_CRTC2;
  153. else
  154. lvds_gen_cntl |= RADEON_LVDS_SEL_CRTC2;
  155. }
  156. WREG32(RADEON_LVDS_GEN_CNTL, lvds_gen_cntl);
  157. WREG32(RADEON_LVDS_PLL_CNTL, lvds_pll_cntl);
  158. WREG32(RADEON_LVDS_SS_GEN_CNTL, lvds_ss_gen_cntl);
  159. if (rdev->family == CHIP_RV410)
  160. WREG32(RADEON_CLOCK_CNTL_INDEX, 0);
  161. if (rdev->is_atom_bios)
  162. radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  163. else
  164. radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  165. }
  166. static bool radeon_legacy_lvds_mode_fixup(struct drm_encoder *encoder,
  167. struct drm_display_mode *mode,
  168. struct drm_display_mode *adjusted_mode)
  169. {
  170. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  171. drm_mode_set_crtcinfo(adjusted_mode, 0);
  172. if (radeon_encoder->rmx_type != RMX_OFF)
  173. radeon_rmx_mode_fixup(encoder, mode, adjusted_mode);
  174. return true;
  175. }
  176. static const struct drm_encoder_helper_funcs radeon_legacy_lvds_helper_funcs = {
  177. .dpms = radeon_legacy_lvds_dpms,
  178. .mode_fixup = radeon_legacy_lvds_mode_fixup,
  179. .prepare = radeon_legacy_lvds_prepare,
  180. .mode_set = radeon_legacy_lvds_mode_set,
  181. .commit = radeon_legacy_lvds_commit,
  182. .disable = radeon_legacy_encoder_disable,
  183. };
  184. static const struct drm_encoder_funcs radeon_legacy_lvds_enc_funcs = {
  185. .destroy = radeon_enc_destroy,
  186. };
  187. static bool radeon_legacy_primary_dac_mode_fixup(struct drm_encoder *encoder,
  188. struct drm_display_mode *mode,
  189. struct drm_display_mode *adjusted_mode)
  190. {
  191. drm_mode_set_crtcinfo(adjusted_mode, 0);
  192. return true;
  193. }
  194. static void radeon_legacy_primary_dac_dpms(struct drm_encoder *encoder, int mode)
  195. {
  196. struct drm_device *dev = encoder->dev;
  197. struct radeon_device *rdev = dev->dev_private;
  198. uint32_t crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
  199. uint32_t dac_cntl = RREG32(RADEON_DAC_CNTL);
  200. uint32_t dac_macro_cntl = RREG32(RADEON_DAC_MACRO_CNTL);
  201. DRM_DEBUG("\n");
  202. switch (mode) {
  203. case DRM_MODE_DPMS_ON:
  204. crtc_ext_cntl |= RADEON_CRTC_CRT_ON;
  205. dac_cntl &= ~RADEON_DAC_PDWN;
  206. dac_macro_cntl &= ~(RADEON_DAC_PDWN_R |
  207. RADEON_DAC_PDWN_G |
  208. RADEON_DAC_PDWN_B);
  209. break;
  210. case DRM_MODE_DPMS_STANDBY:
  211. case DRM_MODE_DPMS_SUSPEND:
  212. case DRM_MODE_DPMS_OFF:
  213. crtc_ext_cntl &= ~RADEON_CRTC_CRT_ON;
  214. dac_cntl |= RADEON_DAC_PDWN;
  215. dac_macro_cntl |= (RADEON_DAC_PDWN_R |
  216. RADEON_DAC_PDWN_G |
  217. RADEON_DAC_PDWN_B);
  218. break;
  219. }
  220. WREG32(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl);
  221. WREG32(RADEON_DAC_CNTL, dac_cntl);
  222. WREG32(RADEON_DAC_MACRO_CNTL, dac_macro_cntl);
  223. if (rdev->is_atom_bios)
  224. radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  225. else
  226. radeon_combios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  227. }
  228. static void radeon_legacy_primary_dac_prepare(struct drm_encoder *encoder)
  229. {
  230. struct radeon_device *rdev = encoder->dev->dev_private;
  231. if (rdev->is_atom_bios)
  232. radeon_atom_output_lock(encoder, true);
  233. else
  234. radeon_combios_output_lock(encoder, true);
  235. radeon_legacy_primary_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
  236. radeon_encoder_set_active_device(encoder);
  237. }
  238. static void radeon_legacy_primary_dac_commit(struct drm_encoder *encoder)
  239. {
  240. struct radeon_device *rdev = encoder->dev->dev_private;
  241. radeon_legacy_primary_dac_dpms(encoder, DRM_MODE_DPMS_ON);
  242. if (rdev->is_atom_bios)
  243. radeon_atom_output_lock(encoder, false);
  244. else
  245. radeon_combios_output_lock(encoder, false);
  246. }
  247. static void radeon_legacy_primary_dac_mode_set(struct drm_encoder *encoder,
  248. struct drm_display_mode *mode,
  249. struct drm_display_mode *adjusted_mode)
  250. {
  251. struct drm_device *dev = encoder->dev;
  252. struct radeon_device *rdev = dev->dev_private;
  253. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  254. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  255. uint32_t disp_output_cntl, dac_cntl, dac2_cntl, dac_macro_cntl;
  256. DRM_DEBUG("\n");
  257. if (radeon_crtc->crtc_id == 0) {
  258. if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev)) {
  259. disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL) &
  260. ~(RADEON_DISP_DAC_SOURCE_MASK);
  261. WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
  262. } else {
  263. dac2_cntl = RREG32(RADEON_DAC_CNTL2) & ~(RADEON_DAC2_DAC_CLK_SEL);
  264. WREG32(RADEON_DAC_CNTL2, dac2_cntl);
  265. }
  266. } else {
  267. if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev)) {
  268. disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL) &
  269. ~(RADEON_DISP_DAC_SOURCE_MASK);
  270. disp_output_cntl |= RADEON_DISP_DAC_SOURCE_CRTC2;
  271. WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
  272. } else {
  273. dac2_cntl = RREG32(RADEON_DAC_CNTL2) | RADEON_DAC2_DAC_CLK_SEL;
  274. WREG32(RADEON_DAC_CNTL2, dac2_cntl);
  275. }
  276. }
  277. dac_cntl = (RADEON_DAC_MASK_ALL |
  278. RADEON_DAC_VGA_ADR_EN |
  279. /* TODO 6-bits */
  280. RADEON_DAC_8BIT_EN);
  281. WREG32_P(RADEON_DAC_CNTL,
  282. dac_cntl,
  283. RADEON_DAC_RANGE_CNTL |
  284. RADEON_DAC_BLANKING);
  285. if (radeon_encoder->enc_priv) {
  286. struct radeon_encoder_primary_dac *p_dac = (struct radeon_encoder_primary_dac *)radeon_encoder->enc_priv;
  287. dac_macro_cntl = p_dac->ps2_pdac_adj;
  288. } else
  289. dac_macro_cntl = RREG32(RADEON_DAC_MACRO_CNTL);
  290. dac_macro_cntl |= RADEON_DAC_PDWN_R | RADEON_DAC_PDWN_G | RADEON_DAC_PDWN_B;
  291. WREG32(RADEON_DAC_MACRO_CNTL, dac_macro_cntl);
  292. if (rdev->is_atom_bios)
  293. radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  294. else
  295. radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  296. }
  297. static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_encoder *encoder,
  298. struct drm_connector *connector)
  299. {
  300. struct drm_device *dev = encoder->dev;
  301. struct radeon_device *rdev = dev->dev_private;
  302. uint32_t vclk_ecp_cntl, crtc_ext_cntl;
  303. uint32_t dac_ext_cntl, dac_cntl, dac_macro_cntl, tmp;
  304. enum drm_connector_status found = connector_status_disconnected;
  305. bool color = true;
  306. /* save the regs we need */
  307. vclk_ecp_cntl = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
  308. crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
  309. dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL);
  310. dac_cntl = RREG32(RADEON_DAC_CNTL);
  311. dac_macro_cntl = RREG32(RADEON_DAC_MACRO_CNTL);
  312. tmp = vclk_ecp_cntl &
  313. ~(RADEON_PIXCLK_ALWAYS_ONb | RADEON_PIXCLK_DAC_ALWAYS_ONb);
  314. WREG32_PLL(RADEON_VCLK_ECP_CNTL, tmp);
  315. tmp = crtc_ext_cntl | RADEON_CRTC_CRT_ON;
  316. WREG32(RADEON_CRTC_EXT_CNTL, tmp);
  317. tmp = RADEON_DAC_FORCE_BLANK_OFF_EN |
  318. RADEON_DAC_FORCE_DATA_EN;
  319. if (color)
  320. tmp |= RADEON_DAC_FORCE_DATA_SEL_RGB;
  321. else
  322. tmp |= RADEON_DAC_FORCE_DATA_SEL_G;
  323. if (ASIC_IS_R300(rdev))
  324. tmp |= (0x1b6 << RADEON_DAC_FORCE_DATA_SHIFT);
  325. else
  326. tmp |= (0x180 << RADEON_DAC_FORCE_DATA_SHIFT);
  327. WREG32(RADEON_DAC_EXT_CNTL, tmp);
  328. tmp = dac_cntl & ~(RADEON_DAC_RANGE_CNTL_MASK | RADEON_DAC_PDWN);
  329. tmp |= RADEON_DAC_RANGE_CNTL_PS2 | RADEON_DAC_CMP_EN;
  330. WREG32(RADEON_DAC_CNTL, tmp);
  331. tmp &= ~(RADEON_DAC_PDWN_R |
  332. RADEON_DAC_PDWN_G |
  333. RADEON_DAC_PDWN_B);
  334. WREG32(RADEON_DAC_MACRO_CNTL, tmp);
  335. udelay(2000);
  336. if (RREG32(RADEON_DAC_CNTL) & RADEON_DAC_CMP_OUTPUT)
  337. found = connector_status_connected;
  338. /* restore the regs we used */
  339. WREG32(RADEON_DAC_CNTL, dac_cntl);
  340. WREG32(RADEON_DAC_MACRO_CNTL, dac_macro_cntl);
  341. WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl);
  342. WREG32(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl);
  343. WREG32_PLL(RADEON_VCLK_ECP_CNTL, vclk_ecp_cntl);
  344. return found;
  345. }
  346. static const struct drm_encoder_helper_funcs radeon_legacy_primary_dac_helper_funcs = {
  347. .dpms = radeon_legacy_primary_dac_dpms,
  348. .mode_fixup = radeon_legacy_primary_dac_mode_fixup,
  349. .prepare = radeon_legacy_primary_dac_prepare,
  350. .mode_set = radeon_legacy_primary_dac_mode_set,
  351. .commit = radeon_legacy_primary_dac_commit,
  352. .detect = radeon_legacy_primary_dac_detect,
  353. .disable = radeon_legacy_encoder_disable,
  354. };
  355. static const struct drm_encoder_funcs radeon_legacy_primary_dac_enc_funcs = {
  356. .destroy = radeon_enc_destroy,
  357. };
  358. static bool radeon_legacy_tmds_int_mode_fixup(struct drm_encoder *encoder,
  359. struct drm_display_mode *mode,
  360. struct drm_display_mode *adjusted_mode)
  361. {
  362. drm_mode_set_crtcinfo(adjusted_mode, 0);
  363. return true;
  364. }
  365. static void radeon_legacy_tmds_int_dpms(struct drm_encoder *encoder, int mode)
  366. {
  367. struct drm_device *dev = encoder->dev;
  368. struct radeon_device *rdev = dev->dev_private;
  369. uint32_t fp_gen_cntl = RREG32(RADEON_FP_GEN_CNTL);
  370. DRM_DEBUG("\n");
  371. switch (mode) {
  372. case DRM_MODE_DPMS_ON:
  373. fp_gen_cntl |= (RADEON_FP_FPON | RADEON_FP_TMDS_EN);
  374. break;
  375. case DRM_MODE_DPMS_STANDBY:
  376. case DRM_MODE_DPMS_SUSPEND:
  377. case DRM_MODE_DPMS_OFF:
  378. fp_gen_cntl &= ~(RADEON_FP_FPON | RADEON_FP_TMDS_EN);
  379. break;
  380. }
  381. WREG32(RADEON_FP_GEN_CNTL, fp_gen_cntl);
  382. if (rdev->is_atom_bios)
  383. radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  384. else
  385. radeon_combios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  386. }
  387. static void radeon_legacy_tmds_int_prepare(struct drm_encoder *encoder)
  388. {
  389. struct radeon_device *rdev = encoder->dev->dev_private;
  390. if (rdev->is_atom_bios)
  391. radeon_atom_output_lock(encoder, true);
  392. else
  393. radeon_combios_output_lock(encoder, true);
  394. radeon_legacy_tmds_int_dpms(encoder, DRM_MODE_DPMS_OFF);
  395. radeon_encoder_set_active_device(encoder);
  396. }
  397. static void radeon_legacy_tmds_int_commit(struct drm_encoder *encoder)
  398. {
  399. struct radeon_device *rdev = encoder->dev->dev_private;
  400. radeon_legacy_tmds_int_dpms(encoder, DRM_MODE_DPMS_ON);
  401. if (rdev->is_atom_bios)
  402. radeon_atom_output_lock(encoder, true);
  403. else
  404. radeon_combios_output_lock(encoder, true);
  405. }
  406. static void radeon_legacy_tmds_int_mode_set(struct drm_encoder *encoder,
  407. struct drm_display_mode *mode,
  408. struct drm_display_mode *adjusted_mode)
  409. {
  410. struct drm_device *dev = encoder->dev;
  411. struct radeon_device *rdev = dev->dev_private;
  412. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  413. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  414. uint32_t tmp, tmds_pll_cntl, tmds_transmitter_cntl, fp_gen_cntl;
  415. int i;
  416. DRM_DEBUG("\n");
  417. tmp = tmds_pll_cntl = RREG32(RADEON_TMDS_PLL_CNTL);
  418. tmp &= 0xfffff;
  419. if (rdev->family == CHIP_RV280) {
  420. /* bit 22 of TMDS_PLL_CNTL is read-back inverted */
  421. tmp ^= (1 << 22);
  422. tmds_pll_cntl ^= (1 << 22);
  423. }
  424. if (radeon_encoder->enc_priv) {
  425. struct radeon_encoder_int_tmds *tmds = (struct radeon_encoder_int_tmds *)radeon_encoder->enc_priv;
  426. for (i = 0; i < 4; i++) {
  427. if (tmds->tmds_pll[i].freq == 0)
  428. break;
  429. if ((uint32_t)(mode->clock / 10) < tmds->tmds_pll[i].freq) {
  430. tmp = tmds->tmds_pll[i].value ;
  431. break;
  432. }
  433. }
  434. }
  435. if (ASIC_IS_R300(rdev) || (rdev->family == CHIP_RV280)) {
  436. if (tmp & 0xfff00000)
  437. tmds_pll_cntl = tmp;
  438. else {
  439. tmds_pll_cntl &= 0xfff00000;
  440. tmds_pll_cntl |= tmp;
  441. }
  442. } else
  443. tmds_pll_cntl = tmp;
  444. tmds_transmitter_cntl = RREG32(RADEON_TMDS_TRANSMITTER_CNTL) &
  445. ~(RADEON_TMDS_TRANSMITTER_PLLRST);
  446. if (rdev->family == CHIP_R200 ||
  447. rdev->family == CHIP_R100 ||
  448. ASIC_IS_R300(rdev))
  449. tmds_transmitter_cntl &= ~(RADEON_TMDS_TRANSMITTER_PLLEN);
  450. else /* RV chips got this bit reversed */
  451. tmds_transmitter_cntl |= RADEON_TMDS_TRANSMITTER_PLLEN;
  452. fp_gen_cntl = (RREG32(RADEON_FP_GEN_CNTL) |
  453. (RADEON_FP_CRTC_DONT_SHADOW_VPAR |
  454. RADEON_FP_CRTC_DONT_SHADOW_HEND));
  455. fp_gen_cntl &= ~(RADEON_FP_FPON | RADEON_FP_TMDS_EN);
  456. if (1) /* FIXME rgbBits == 8 */
  457. fp_gen_cntl |= RADEON_FP_PANEL_FORMAT; /* 24 bit format */
  458. else
  459. fp_gen_cntl &= ~RADEON_FP_PANEL_FORMAT;/* 18 bit format */
  460. if (radeon_crtc->crtc_id == 0) {
  461. if (ASIC_IS_R300(rdev) || rdev->family == CHIP_R200) {
  462. fp_gen_cntl &= ~R200_FP_SOURCE_SEL_MASK;
  463. if (radeon_encoder->rmx_type != RMX_OFF)
  464. fp_gen_cntl |= R200_FP_SOURCE_SEL_RMX;
  465. else
  466. fp_gen_cntl |= R200_FP_SOURCE_SEL_CRTC1;
  467. } else
  468. fp_gen_cntl |= RADEON_FP_SEL_CRTC1;
  469. } else {
  470. if (ASIC_IS_R300(rdev) || rdev->family == CHIP_R200) {
  471. fp_gen_cntl &= ~R200_FP_SOURCE_SEL_MASK;
  472. fp_gen_cntl |= R200_FP_SOURCE_SEL_CRTC2;
  473. } else
  474. fp_gen_cntl |= RADEON_FP_SEL_CRTC2;
  475. }
  476. WREG32(RADEON_TMDS_PLL_CNTL, tmds_pll_cntl);
  477. WREG32(RADEON_TMDS_TRANSMITTER_CNTL, tmds_transmitter_cntl);
  478. WREG32(RADEON_FP_GEN_CNTL, fp_gen_cntl);
  479. if (rdev->is_atom_bios)
  480. radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  481. else
  482. radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  483. }
  484. static const struct drm_encoder_helper_funcs radeon_legacy_tmds_int_helper_funcs = {
  485. .dpms = radeon_legacy_tmds_int_dpms,
  486. .mode_fixup = radeon_legacy_tmds_int_mode_fixup,
  487. .prepare = radeon_legacy_tmds_int_prepare,
  488. .mode_set = radeon_legacy_tmds_int_mode_set,
  489. .commit = radeon_legacy_tmds_int_commit,
  490. .disable = radeon_legacy_encoder_disable,
  491. };
  492. static const struct drm_encoder_funcs radeon_legacy_tmds_int_enc_funcs = {
  493. .destroy = radeon_enc_destroy,
  494. };
  495. static bool radeon_legacy_tmds_ext_mode_fixup(struct drm_encoder *encoder,
  496. struct drm_display_mode *mode,
  497. struct drm_display_mode *adjusted_mode)
  498. {
  499. drm_mode_set_crtcinfo(adjusted_mode, 0);
  500. return true;
  501. }
  502. static void radeon_legacy_tmds_ext_dpms(struct drm_encoder *encoder, int mode)
  503. {
  504. struct drm_device *dev = encoder->dev;
  505. struct radeon_device *rdev = dev->dev_private;
  506. uint32_t fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
  507. DRM_DEBUG("\n");
  508. switch (mode) {
  509. case DRM_MODE_DPMS_ON:
  510. fp2_gen_cntl &= ~RADEON_FP2_BLANK_EN;
  511. fp2_gen_cntl |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN);
  512. break;
  513. case DRM_MODE_DPMS_STANDBY:
  514. case DRM_MODE_DPMS_SUSPEND:
  515. case DRM_MODE_DPMS_OFF:
  516. fp2_gen_cntl |= RADEON_FP2_BLANK_EN;
  517. fp2_gen_cntl &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN);
  518. break;
  519. }
  520. WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
  521. if (rdev->is_atom_bios)
  522. radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  523. else
  524. radeon_combios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  525. }
  526. static void radeon_legacy_tmds_ext_prepare(struct drm_encoder *encoder)
  527. {
  528. struct radeon_device *rdev = encoder->dev->dev_private;
  529. if (rdev->is_atom_bios)
  530. radeon_atom_output_lock(encoder, true);
  531. else
  532. radeon_combios_output_lock(encoder, true);
  533. radeon_legacy_tmds_ext_dpms(encoder, DRM_MODE_DPMS_OFF);
  534. radeon_encoder_set_active_device(encoder);
  535. }
  536. static void radeon_legacy_tmds_ext_commit(struct drm_encoder *encoder)
  537. {
  538. struct radeon_device *rdev = encoder->dev->dev_private;
  539. radeon_legacy_tmds_ext_dpms(encoder, DRM_MODE_DPMS_ON);
  540. if (rdev->is_atom_bios)
  541. radeon_atom_output_lock(encoder, false);
  542. else
  543. radeon_combios_output_lock(encoder, false);
  544. }
  545. static void radeon_legacy_tmds_ext_mode_set(struct drm_encoder *encoder,
  546. struct drm_display_mode *mode,
  547. struct drm_display_mode *adjusted_mode)
  548. {
  549. struct drm_device *dev = encoder->dev;
  550. struct radeon_device *rdev = dev->dev_private;
  551. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  552. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  553. uint32_t fp2_gen_cntl;
  554. DRM_DEBUG("\n");
  555. if (rdev->is_atom_bios) {
  556. radeon_encoder->pixel_clock = adjusted_mode->clock;
  557. atombios_external_tmds_setup(encoder, ATOM_ENABLE);
  558. fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
  559. } else {
  560. fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
  561. if (1) /* FIXME rgbBits == 8 */
  562. fp2_gen_cntl |= RADEON_FP2_PANEL_FORMAT; /* 24 bit format, */
  563. else
  564. fp2_gen_cntl &= ~RADEON_FP2_PANEL_FORMAT;/* 18 bit format, */
  565. fp2_gen_cntl &= ~(RADEON_FP2_ON |
  566. RADEON_FP2_DVO_EN |
  567. RADEON_FP2_DVO_RATE_SEL_SDR);
  568. /* XXX: these are oem specific */
  569. if (ASIC_IS_R300(rdev)) {
  570. if ((dev->pdev->device == 0x4850) &&
  571. (dev->pdev->subsystem_vendor == 0x1028) &&
  572. (dev->pdev->subsystem_device == 0x2001)) /* Dell Inspiron 8600 */
  573. fp2_gen_cntl |= R300_FP2_DVO_CLOCK_MODE_SINGLE;
  574. else
  575. fp2_gen_cntl |= RADEON_FP2_PAD_FLOP_EN | R300_FP2_DVO_CLOCK_MODE_SINGLE;
  576. /*if (mode->clock > 165000)
  577. fp2_gen_cntl |= R300_FP2_DVO_DUAL_CHANNEL_EN;*/
  578. }
  579. }
  580. if (radeon_crtc->crtc_id == 0) {
  581. if ((rdev->family == CHIP_R200) || ASIC_IS_R300(rdev)) {
  582. fp2_gen_cntl &= ~R200_FP2_SOURCE_SEL_MASK;
  583. if (radeon_encoder->rmx_type != RMX_OFF)
  584. fp2_gen_cntl |= R200_FP2_SOURCE_SEL_RMX;
  585. else
  586. fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC1;
  587. } else
  588. fp2_gen_cntl &= ~RADEON_FP2_SRC_SEL_CRTC2;
  589. } else {
  590. if ((rdev->family == CHIP_R200) || ASIC_IS_R300(rdev)) {
  591. fp2_gen_cntl &= ~R200_FP2_SOURCE_SEL_MASK;
  592. fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC2;
  593. } else
  594. fp2_gen_cntl |= RADEON_FP2_SRC_SEL_CRTC2;
  595. }
  596. WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
  597. if (rdev->is_atom_bios)
  598. radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  599. else
  600. radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  601. }
  602. static const struct drm_encoder_helper_funcs radeon_legacy_tmds_ext_helper_funcs = {
  603. .dpms = radeon_legacy_tmds_ext_dpms,
  604. .mode_fixup = radeon_legacy_tmds_ext_mode_fixup,
  605. .prepare = radeon_legacy_tmds_ext_prepare,
  606. .mode_set = radeon_legacy_tmds_ext_mode_set,
  607. .commit = radeon_legacy_tmds_ext_commit,
  608. .disable = radeon_legacy_encoder_disable,
  609. };
  610. static const struct drm_encoder_funcs radeon_legacy_tmds_ext_enc_funcs = {
  611. .destroy = radeon_enc_destroy,
  612. };
  613. static bool radeon_legacy_tv_dac_mode_fixup(struct drm_encoder *encoder,
  614. struct drm_display_mode *mode,
  615. struct drm_display_mode *adjusted_mode)
  616. {
  617. drm_mode_set_crtcinfo(adjusted_mode, 0);
  618. return true;
  619. }
  620. static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
  621. {
  622. struct drm_device *dev = encoder->dev;
  623. struct radeon_device *rdev = dev->dev_private;
  624. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  625. uint32_t fp2_gen_cntl = 0, crtc2_gen_cntl = 0, tv_dac_cntl = 0;
  626. uint32_t tv_master_cntl = 0;
  627. bool is_tv;
  628. DRM_DEBUG("\n");
  629. is_tv = radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT ? true : false;
  630. if (rdev->family == CHIP_R200)
  631. fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
  632. else {
  633. if (is_tv)
  634. tv_master_cntl = RREG32(RADEON_TV_MASTER_CNTL);
  635. else
  636. crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
  637. tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
  638. }
  639. switch (mode) {
  640. case DRM_MODE_DPMS_ON:
  641. if (rdev->family == CHIP_R200) {
  642. fp2_gen_cntl |= (RADEON_FP2_ON | RADEON_FP2_DVO_EN);
  643. } else {
  644. if (is_tv)
  645. tv_master_cntl |= RADEON_TV_ON;
  646. else
  647. crtc2_gen_cntl |= RADEON_CRTC2_CRT2_ON;
  648. if (rdev->family == CHIP_R420 ||
  649. rdev->family == CHIP_R423 ||
  650. rdev->family == CHIP_RV410)
  651. tv_dac_cntl &= ~(R420_TV_DAC_RDACPD |
  652. R420_TV_DAC_GDACPD |
  653. R420_TV_DAC_BDACPD |
  654. RADEON_TV_DAC_BGSLEEP);
  655. else
  656. tv_dac_cntl &= ~(RADEON_TV_DAC_RDACPD |
  657. RADEON_TV_DAC_GDACPD |
  658. RADEON_TV_DAC_BDACPD |
  659. RADEON_TV_DAC_BGSLEEP);
  660. }
  661. break;
  662. case DRM_MODE_DPMS_STANDBY:
  663. case DRM_MODE_DPMS_SUSPEND:
  664. case DRM_MODE_DPMS_OFF:
  665. if (rdev->family == CHIP_R200)
  666. fp2_gen_cntl &= ~(RADEON_FP2_ON | RADEON_FP2_DVO_EN);
  667. else {
  668. if (is_tv)
  669. tv_master_cntl &= ~RADEON_TV_ON;
  670. else
  671. crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON;
  672. if (rdev->family == CHIP_R420 ||
  673. rdev->family == CHIP_R423 ||
  674. rdev->family == CHIP_RV410)
  675. tv_dac_cntl |= (R420_TV_DAC_RDACPD |
  676. R420_TV_DAC_GDACPD |
  677. R420_TV_DAC_BDACPD |
  678. RADEON_TV_DAC_BGSLEEP);
  679. else
  680. tv_dac_cntl |= (RADEON_TV_DAC_RDACPD |
  681. RADEON_TV_DAC_GDACPD |
  682. RADEON_TV_DAC_BDACPD |
  683. RADEON_TV_DAC_BGSLEEP);
  684. }
  685. break;
  686. }
  687. if (rdev->family == CHIP_R200) {
  688. WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
  689. } else {
  690. if (is_tv)
  691. WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl);
  692. else
  693. WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
  694. WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
  695. }
  696. if (rdev->is_atom_bios)
  697. radeon_atombios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  698. else
  699. radeon_combios_encoder_dpms_scratch_regs(encoder, (mode == DRM_MODE_DPMS_ON) ? true : false);
  700. }
  701. static void radeon_legacy_tv_dac_prepare(struct drm_encoder *encoder)
  702. {
  703. struct radeon_device *rdev = encoder->dev->dev_private;
  704. if (rdev->is_atom_bios)
  705. radeon_atom_output_lock(encoder, true);
  706. else
  707. radeon_combios_output_lock(encoder, true);
  708. radeon_legacy_tv_dac_dpms(encoder, DRM_MODE_DPMS_OFF);
  709. radeon_encoder_set_active_device(encoder);
  710. }
  711. static void radeon_legacy_tv_dac_commit(struct drm_encoder *encoder)
  712. {
  713. struct radeon_device *rdev = encoder->dev->dev_private;
  714. radeon_legacy_tv_dac_dpms(encoder, DRM_MODE_DPMS_ON);
  715. if (rdev->is_atom_bios)
  716. radeon_atom_output_lock(encoder, true);
  717. else
  718. radeon_combios_output_lock(encoder, true);
  719. }
  720. static void radeon_legacy_tv_dac_mode_set(struct drm_encoder *encoder,
  721. struct drm_display_mode *mode,
  722. struct drm_display_mode *adjusted_mode)
  723. {
  724. struct drm_device *dev = encoder->dev;
  725. struct radeon_device *rdev = dev->dev_private;
  726. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  727. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  728. struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
  729. uint32_t tv_dac_cntl, gpiopad_a = 0, dac2_cntl, disp_output_cntl = 0;
  730. uint32_t disp_hw_debug = 0, fp2_gen_cntl = 0, disp_tv_out_cntl = 0;
  731. bool is_tv = false;
  732. DRM_DEBUG("\n");
  733. is_tv = radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT ? true : false;
  734. if (rdev->family != CHIP_R200) {
  735. tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
  736. if (rdev->family == CHIP_R420 ||
  737. rdev->family == CHIP_R423 ||
  738. rdev->family == CHIP_RV410) {
  739. tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK |
  740. RADEON_TV_DAC_BGADJ_MASK |
  741. R420_TV_DAC_DACADJ_MASK |
  742. R420_TV_DAC_RDACPD |
  743. R420_TV_DAC_GDACPD |
  744. R420_TV_DAC_GDACPD |
  745. R420_TV_DAC_TVENABLE);
  746. } else {
  747. tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK |
  748. RADEON_TV_DAC_BGADJ_MASK |
  749. RADEON_TV_DAC_DACADJ_MASK |
  750. RADEON_TV_DAC_RDACPD |
  751. RADEON_TV_DAC_GDACPD |
  752. RADEON_TV_DAC_GDACPD);
  753. }
  754. /* FIXME TV */
  755. if (tv_dac) {
  756. struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
  757. tv_dac_cntl |= (RADEON_TV_DAC_NBLANK |
  758. RADEON_TV_DAC_NHOLD |
  759. RADEON_TV_DAC_STD_PS2 |
  760. tv_dac->ps2_tvdac_adj);
  761. } else
  762. tv_dac_cntl |= (RADEON_TV_DAC_NBLANK |
  763. RADEON_TV_DAC_NHOLD |
  764. RADEON_TV_DAC_STD_PS2);
  765. WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
  766. }
  767. if (ASIC_IS_R300(rdev)) {
  768. gpiopad_a = RREG32(RADEON_GPIOPAD_A) | 1;
  769. disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
  770. }
  771. if (rdev->family == CHIP_R200 || ASIC_IS_R300(rdev))
  772. disp_tv_out_cntl = RREG32(RADEON_DISP_TV_OUT_CNTL);
  773. else
  774. disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG);
  775. if (rdev->family == CHIP_R200)
  776. fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
  777. if (is_tv) {
  778. uint32_t dac_cntl;
  779. dac_cntl = RREG32(RADEON_DAC_CNTL);
  780. dac_cntl &= ~RADEON_DAC_TVO_EN;
  781. WREG32(RADEON_DAC_CNTL, dac_cntl);
  782. if (ASIC_IS_R300(rdev))
  783. gpiopad_a = RREG32(RADEON_GPIOPAD_A) & ~1;
  784. dac2_cntl = RREG32(RADEON_DAC_CNTL2) & ~RADEON_DAC2_DAC2_CLK_SEL;
  785. if (radeon_crtc->crtc_id == 0) {
  786. if (ASIC_IS_R300(rdev)) {
  787. disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
  788. disp_output_cntl |= (RADEON_DISP_TVDAC_SOURCE_CRTC |
  789. RADEON_DISP_TV_SOURCE_CRTC);
  790. }
  791. if (rdev->family >= CHIP_R200) {
  792. disp_tv_out_cntl &= ~RADEON_DISP_TV_PATH_SRC_CRTC2;
  793. } else {
  794. disp_hw_debug |= RADEON_CRT2_DISP1_SEL;
  795. }
  796. } else {
  797. if (ASIC_IS_R300(rdev)) {
  798. disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
  799. disp_output_cntl |= RADEON_DISP_TV_SOURCE_CRTC;
  800. }
  801. if (rdev->family >= CHIP_R200) {
  802. disp_tv_out_cntl |= RADEON_DISP_TV_PATH_SRC_CRTC2;
  803. } else {
  804. disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
  805. }
  806. }
  807. WREG32(RADEON_DAC_CNTL2, dac2_cntl);
  808. } else {
  809. dac2_cntl = RREG32(RADEON_DAC_CNTL2) | RADEON_DAC2_DAC2_CLK_SEL;
  810. if (radeon_crtc->crtc_id == 0) {
  811. if (ASIC_IS_R300(rdev)) {
  812. disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
  813. disp_output_cntl |= RADEON_DISP_TVDAC_SOURCE_CRTC;
  814. } else if (rdev->family == CHIP_R200) {
  815. fp2_gen_cntl &= ~(R200_FP2_SOURCE_SEL_MASK |
  816. RADEON_FP2_DVO_RATE_SEL_SDR);
  817. } else
  818. disp_hw_debug |= RADEON_CRT2_DISP1_SEL;
  819. } else {
  820. if (ASIC_IS_R300(rdev)) {
  821. disp_output_cntl &= ~RADEON_DISP_TVDAC_SOURCE_MASK;
  822. disp_output_cntl |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
  823. } else if (rdev->family == CHIP_R200) {
  824. fp2_gen_cntl &= ~(R200_FP2_SOURCE_SEL_MASK |
  825. RADEON_FP2_DVO_RATE_SEL_SDR);
  826. fp2_gen_cntl |= R200_FP2_SOURCE_SEL_CRTC2;
  827. } else
  828. disp_hw_debug &= ~RADEON_CRT2_DISP1_SEL;
  829. }
  830. WREG32(RADEON_DAC_CNTL2, dac2_cntl);
  831. }
  832. if (ASIC_IS_R300(rdev)) {
  833. WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
  834. WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
  835. }
  836. if (rdev->family >= CHIP_R200)
  837. WREG32(RADEON_DISP_TV_OUT_CNTL, disp_tv_out_cntl);
  838. else
  839. WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
  840. if (rdev->family == CHIP_R200)
  841. WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
  842. if (is_tv)
  843. radeon_legacy_tv_mode_set(encoder, mode, adjusted_mode);
  844. if (rdev->is_atom_bios)
  845. radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  846. else
  847. radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
  848. }
  849. static bool r300_legacy_tv_detect(struct drm_encoder *encoder,
  850. struct drm_connector *connector)
  851. {
  852. struct drm_device *dev = encoder->dev;
  853. struct radeon_device *rdev = dev->dev_private;
  854. uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
  855. uint32_t disp_output_cntl, gpiopad_a, tmp;
  856. bool found = false;
  857. /* save regs needed */
  858. gpiopad_a = RREG32(RADEON_GPIOPAD_A);
  859. dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
  860. crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
  861. dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL);
  862. tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
  863. disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
  864. WREG32_P(RADEON_GPIOPAD_A, 0, ~1);
  865. WREG32(RADEON_DAC_CNTL2, RADEON_DAC2_DAC2_CLK_SEL);
  866. WREG32(RADEON_CRTC2_GEN_CNTL,
  867. RADEON_CRTC2_CRT2_ON | RADEON_CRTC2_VSYNC_TRISTAT);
  868. tmp = disp_output_cntl & ~RADEON_DISP_TVDAC_SOURCE_MASK;
  869. tmp |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
  870. WREG32(RADEON_DISP_OUTPUT_CNTL, tmp);
  871. WREG32(RADEON_DAC_EXT_CNTL,
  872. RADEON_DAC2_FORCE_BLANK_OFF_EN |
  873. RADEON_DAC2_FORCE_DATA_EN |
  874. RADEON_DAC_FORCE_DATA_SEL_RGB |
  875. (0xec << RADEON_DAC_FORCE_DATA_SHIFT));
  876. WREG32(RADEON_TV_DAC_CNTL,
  877. RADEON_TV_DAC_STD_NTSC |
  878. (8 << RADEON_TV_DAC_BGADJ_SHIFT) |
  879. (6 << RADEON_TV_DAC_DACADJ_SHIFT));
  880. RREG32(RADEON_TV_DAC_CNTL);
  881. mdelay(4);
  882. WREG32(RADEON_TV_DAC_CNTL,
  883. RADEON_TV_DAC_NBLANK |
  884. RADEON_TV_DAC_NHOLD |
  885. RADEON_TV_MONITOR_DETECT_EN |
  886. RADEON_TV_DAC_STD_NTSC |
  887. (8 << RADEON_TV_DAC_BGADJ_SHIFT) |
  888. (6 << RADEON_TV_DAC_DACADJ_SHIFT));
  889. RREG32(RADEON_TV_DAC_CNTL);
  890. mdelay(6);
  891. tmp = RREG32(RADEON_TV_DAC_CNTL);
  892. if ((tmp & RADEON_TV_DAC_GDACDET) != 0) {
  893. found = true;
  894. DRM_DEBUG("S-video TV connection detected\n");
  895. } else if ((tmp & RADEON_TV_DAC_BDACDET) != 0) {
  896. found = true;
  897. DRM_DEBUG("Composite TV connection detected\n");
  898. }
  899. WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
  900. WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl);
  901. WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
  902. WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
  903. WREG32(RADEON_DAC_CNTL2, dac_cntl2);
  904. WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
  905. return found;
  906. }
  907. static bool radeon_legacy_tv_detect(struct drm_encoder *encoder,
  908. struct drm_connector *connector)
  909. {
  910. struct drm_device *dev = encoder->dev;
  911. struct radeon_device *rdev = dev->dev_private;
  912. uint32_t tv_dac_cntl, dac_cntl2;
  913. uint32_t config_cntl, tv_pre_dac_mux_cntl, tv_master_cntl, tmp;
  914. bool found = false;
  915. if (ASIC_IS_R300(rdev))
  916. return r300_legacy_tv_detect(encoder, connector);
  917. dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
  918. tv_master_cntl = RREG32(RADEON_TV_MASTER_CNTL);
  919. tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
  920. config_cntl = RREG32(RADEON_CONFIG_CNTL);
  921. tv_pre_dac_mux_cntl = RREG32(RADEON_TV_PRE_DAC_MUX_CNTL);
  922. tmp = dac_cntl2 & ~RADEON_DAC2_DAC2_CLK_SEL;
  923. WREG32(RADEON_DAC_CNTL2, tmp);
  924. tmp = tv_master_cntl | RADEON_TV_ON;
  925. tmp &= ~(RADEON_TV_ASYNC_RST |
  926. RADEON_RESTART_PHASE_FIX |
  927. RADEON_CRT_FIFO_CE_EN |
  928. RADEON_TV_FIFO_CE_EN |
  929. RADEON_RE_SYNC_NOW_SEL_MASK);
  930. tmp |= RADEON_TV_FIFO_ASYNC_RST | RADEON_CRT_ASYNC_RST;
  931. WREG32(RADEON_TV_MASTER_CNTL, tmp);
  932. tmp = RADEON_TV_DAC_NBLANK | RADEON_TV_DAC_NHOLD |
  933. RADEON_TV_MONITOR_DETECT_EN | RADEON_TV_DAC_STD_NTSC |
  934. (8 << RADEON_TV_DAC_BGADJ_SHIFT);
  935. if (config_cntl & RADEON_CFG_ATI_REV_ID_MASK)
  936. tmp |= (4 << RADEON_TV_DAC_DACADJ_SHIFT);
  937. else
  938. tmp |= (8 << RADEON_TV_DAC_DACADJ_SHIFT);
  939. WREG32(RADEON_TV_DAC_CNTL, tmp);
  940. tmp = RADEON_C_GRN_EN | RADEON_CMP_BLU_EN |
  941. RADEON_RED_MX_FORCE_DAC_DATA |
  942. RADEON_GRN_MX_FORCE_DAC_DATA |
  943. RADEON_BLU_MX_FORCE_DAC_DATA |
  944. (0x109 << RADEON_TV_FORCE_DAC_DATA_SHIFT);
  945. WREG32(RADEON_TV_PRE_DAC_MUX_CNTL, tmp);
  946. mdelay(3);
  947. tmp = RREG32(RADEON_TV_DAC_CNTL);
  948. if (tmp & RADEON_TV_DAC_GDACDET) {
  949. found = true;
  950. DRM_DEBUG("S-video TV connection detected\n");
  951. } else if ((tmp & RADEON_TV_DAC_BDACDET) != 0) {
  952. found = true;
  953. DRM_DEBUG("Composite TV connection detected\n");
  954. }
  955. WREG32(RADEON_TV_PRE_DAC_MUX_CNTL, tv_pre_dac_mux_cntl);
  956. WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
  957. WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl);
  958. WREG32(RADEON_DAC_CNTL2, dac_cntl2);
  959. return found;
  960. }
  961. static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder *encoder,
  962. struct drm_connector *connector)
  963. {
  964. struct drm_device *dev = encoder->dev;
  965. struct radeon_device *rdev = dev->dev_private;
  966. uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
  967. uint32_t disp_hw_debug, disp_output_cntl, gpiopad_a, pixclks_cntl, tmp;
  968. enum drm_connector_status found = connector_status_disconnected;
  969. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  970. struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
  971. bool color = true;
  972. if (connector->connector_type == DRM_MODE_CONNECTOR_SVIDEO ||
  973. connector->connector_type == DRM_MODE_CONNECTOR_Composite ||
  974. connector->connector_type == DRM_MODE_CONNECTOR_9PinDIN) {
  975. bool tv_detect;
  976. if (radeon_encoder->active_device && !(radeon_encoder->active_device & ATOM_DEVICE_TV_SUPPORT))
  977. return connector_status_disconnected;
  978. tv_detect = radeon_legacy_tv_detect(encoder, connector);
  979. if (tv_detect && tv_dac)
  980. found = connector_status_connected;
  981. return found;
  982. }
  983. /* don't probe if the encoder is being used for something else not CRT related */
  984. if (radeon_encoder->active_device && !(radeon_encoder->active_device & ATOM_DEVICE_CRT_SUPPORT)) {
  985. DRM_INFO("not detecting due to %08x\n", radeon_encoder->active_device);
  986. return connector_status_disconnected;
  987. }
  988. /* save the regs we need */
  989. pixclks_cntl = RREG32_PLL(RADEON_PIXCLKS_CNTL);
  990. gpiopad_a = ASIC_IS_R300(rdev) ? RREG32(RADEON_GPIOPAD_A) : 0;
  991. disp_output_cntl = ASIC_IS_R300(rdev) ? RREG32(RADEON_DISP_OUTPUT_CNTL) : 0;
  992. disp_hw_debug = ASIC_IS_R300(rdev) ? 0 : RREG32(RADEON_DISP_HW_DEBUG);
  993. crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
  994. tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
  995. dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL);
  996. dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
  997. tmp = pixclks_cntl & ~(RADEON_PIX2CLK_ALWAYS_ONb
  998. | RADEON_PIX2CLK_DAC_ALWAYS_ONb);
  999. WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
  1000. if (ASIC_IS_R300(rdev))
  1001. WREG32_P(RADEON_GPIOPAD_A, 1, ~1);
  1002. tmp = crtc2_gen_cntl & ~RADEON_CRTC2_PIX_WIDTH_MASK;
  1003. tmp |= RADEON_CRTC2_CRT2_ON |
  1004. (2 << RADEON_CRTC2_PIX_WIDTH_SHIFT);
  1005. WREG32(RADEON_CRTC2_GEN_CNTL, tmp);
  1006. if (ASIC_IS_R300(rdev)) {
  1007. tmp = disp_output_cntl & ~RADEON_DISP_TVDAC_SOURCE_MASK;
  1008. tmp |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
  1009. WREG32(RADEON_DISP_OUTPUT_CNTL, tmp);
  1010. } else {
  1011. tmp = disp_hw_debug & ~RADEON_CRT2_DISP1_SEL;
  1012. WREG32(RADEON_DISP_HW_DEBUG, tmp);
  1013. }
  1014. tmp = RADEON_TV_DAC_NBLANK |
  1015. RADEON_TV_DAC_NHOLD |
  1016. RADEON_TV_MONITOR_DETECT_EN |
  1017. RADEON_TV_DAC_STD_PS2;
  1018. WREG32(RADEON_TV_DAC_CNTL, tmp);
  1019. tmp = RADEON_DAC2_FORCE_BLANK_OFF_EN |
  1020. RADEON_DAC2_FORCE_DATA_EN;
  1021. if (color)
  1022. tmp |= RADEON_DAC_FORCE_DATA_SEL_RGB;
  1023. else
  1024. tmp |= RADEON_DAC_FORCE_DATA_SEL_G;
  1025. if (ASIC_IS_R300(rdev))
  1026. tmp |= (0x1b6 << RADEON_DAC_FORCE_DATA_SHIFT);
  1027. else
  1028. tmp |= (0x180 << RADEON_DAC_FORCE_DATA_SHIFT);
  1029. WREG32(RADEON_DAC_EXT_CNTL, tmp);
  1030. tmp = dac_cntl2 | RADEON_DAC2_DAC2_CLK_SEL | RADEON_DAC2_CMP_EN;
  1031. WREG32(RADEON_DAC_CNTL2, tmp);
  1032. udelay(10000);
  1033. if (ASIC_IS_R300(rdev)) {
  1034. if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUT_B)
  1035. found = connector_status_connected;
  1036. } else {
  1037. if (RREG32(RADEON_DAC_CNTL2) & RADEON_DAC2_CMP_OUTPUT)
  1038. found = connector_status_connected;
  1039. }
  1040. /* restore regs we used */
  1041. WREG32(RADEON_DAC_CNTL2, dac_cntl2);
  1042. WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl);
  1043. WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
  1044. WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
  1045. if (ASIC_IS_R300(rdev)) {
  1046. WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
  1047. WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
  1048. } else {
  1049. WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
  1050. }
  1051. WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
  1052. return found;
  1053. }
  1054. static const struct drm_encoder_helper_funcs radeon_legacy_tv_dac_helper_funcs = {
  1055. .dpms = radeon_legacy_tv_dac_dpms,
  1056. .mode_fixup = radeon_legacy_tv_dac_mode_fixup,
  1057. .prepare = radeon_legacy_tv_dac_prepare,
  1058. .mode_set = radeon_legacy_tv_dac_mode_set,
  1059. .commit = radeon_legacy_tv_dac_commit,
  1060. .detect = radeon_legacy_tv_dac_detect,
  1061. .disable = radeon_legacy_encoder_disable,
  1062. };
  1063. static const struct drm_encoder_funcs radeon_legacy_tv_dac_enc_funcs = {
  1064. .destroy = radeon_enc_destroy,
  1065. };
  1066. static struct radeon_encoder_int_tmds *radeon_legacy_get_tmds_info(struct radeon_encoder *encoder)
  1067. {
  1068. struct drm_device *dev = encoder->base.dev;
  1069. struct radeon_device *rdev = dev->dev_private;
  1070. struct radeon_encoder_int_tmds *tmds = NULL;
  1071. bool ret;
  1072. tmds = kzalloc(sizeof(struct radeon_encoder_int_tmds), GFP_KERNEL);
  1073. if (!tmds)
  1074. return NULL;
  1075. if (rdev->is_atom_bios)
  1076. ret = radeon_atombios_get_tmds_info(encoder, tmds);
  1077. else
  1078. ret = radeon_legacy_get_tmds_info_from_combios(encoder, tmds);
  1079. if (ret == false)
  1080. radeon_legacy_get_tmds_info_from_table(encoder, tmds);
  1081. return tmds;
  1082. }
  1083. void
  1084. radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t supported_device)
  1085. {
  1086. struct radeon_device *rdev = dev->dev_private;
  1087. struct drm_encoder *encoder;
  1088. struct radeon_encoder *radeon_encoder;
  1089. /* see if we already added it */
  1090. list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
  1091. radeon_encoder = to_radeon_encoder(encoder);
  1092. if (radeon_encoder->encoder_id == encoder_id) {
  1093. radeon_encoder->devices |= supported_device;
  1094. return;
  1095. }
  1096. }
  1097. /* add a new one */
  1098. radeon_encoder = kzalloc(sizeof(struct radeon_encoder), GFP_KERNEL);
  1099. if (!radeon_encoder)
  1100. return;
  1101. encoder = &radeon_encoder->base;
  1102. encoder->possible_crtcs = 0x3;
  1103. encoder->possible_clones = 0;
  1104. radeon_encoder->enc_priv = NULL;
  1105. radeon_encoder->encoder_id = encoder_id;
  1106. radeon_encoder->devices = supported_device;
  1107. radeon_encoder->rmx_type = RMX_OFF;
  1108. switch (radeon_encoder->encoder_id) {
  1109. case ENCODER_OBJECT_ID_INTERNAL_LVDS:
  1110. encoder->possible_crtcs = 0x1;
  1111. drm_encoder_init(dev, encoder, &radeon_legacy_lvds_enc_funcs, DRM_MODE_ENCODER_LVDS);
  1112. drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs);
  1113. if (rdev->is_atom_bios)
  1114. radeon_encoder->enc_priv = radeon_atombios_get_lvds_info(radeon_encoder);
  1115. else
  1116. radeon_encoder->enc_priv = radeon_combios_get_lvds_info(radeon_encoder);
  1117. radeon_encoder->rmx_type = RMX_FULL;
  1118. break;
  1119. case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
  1120. drm_encoder_init(dev, encoder, &radeon_legacy_tmds_int_enc_funcs, DRM_MODE_ENCODER_TMDS);
  1121. drm_encoder_helper_add(encoder, &radeon_legacy_tmds_int_helper_funcs);
  1122. radeon_encoder->enc_priv = radeon_legacy_get_tmds_info(radeon_encoder);
  1123. break;
  1124. case ENCODER_OBJECT_ID_INTERNAL_DAC1:
  1125. drm_encoder_init(dev, encoder, &radeon_legacy_primary_dac_enc_funcs, DRM_MODE_ENCODER_DAC);
  1126. drm_encoder_helper_add(encoder, &radeon_legacy_primary_dac_helper_funcs);
  1127. if (rdev->is_atom_bios)
  1128. radeon_encoder->enc_priv = radeon_atombios_get_primary_dac_info(radeon_encoder);
  1129. else
  1130. radeon_encoder->enc_priv = radeon_combios_get_primary_dac_info(radeon_encoder);
  1131. break;
  1132. case ENCODER_OBJECT_ID_INTERNAL_DAC2:
  1133. drm_encoder_init(dev, encoder, &radeon_legacy_tv_dac_enc_funcs, DRM_MODE_ENCODER_TVDAC);
  1134. drm_encoder_helper_add(encoder, &radeon_legacy_tv_dac_helper_funcs);
  1135. if (rdev->is_atom_bios)
  1136. radeon_encoder->enc_priv = radeon_atombios_get_tv_dac_info(radeon_encoder);
  1137. else
  1138. radeon_encoder->enc_priv = radeon_combios_get_tv_dac_info(radeon_encoder);
  1139. break;
  1140. case ENCODER_OBJECT_ID_INTERNAL_DVO1:
  1141. drm_encoder_init(dev, encoder, &radeon_legacy_tmds_ext_enc_funcs, DRM_MODE_ENCODER_TMDS);
  1142. drm_encoder_helper_add(encoder, &radeon_legacy_tmds_ext_helper_funcs);
  1143. if (!rdev->is_atom_bios)
  1144. radeon_combios_get_ext_tmds_info(radeon_encoder);
  1145. break;
  1146. }
  1147. }