radeon_legacy_encoders.c 43 KB

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