43 "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n"
44 "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n"
46 "\t\t*NOTE* Ignored for cards with external TV encoders.");
47 static char *nouveau_tv_norm;
56 uint32_t gpio0, gpio1, fp_htotal, fp_hsync_start, fp_hsync_end,
57 fp_control, test_ctrl, dacclk, ctv_14, ctv_1c, ctv_6c;
61 #define RGB_TEST_DATA(r, g, b) (r << 0 | g << 10 | b << 20)
63 if (drm->
vbios.tvdactestval)
64 testval = drm->
vbios.tvdactestval;
67 head = (dacclk & 0x100) >> 8;
77 ctv_1c = NVReadRAMDAC(dev, head, 0x680c1c);
78 ctv_14 = NVReadRAMDAC(dev, head, 0x680c14);
79 ctv_6c = NVReadRAMDAC(dev, head, 0x680c6c);
98 (dacclk & ~0xff) | 0x22);
101 (dacclk & ~0xff) | 0x21);
103 NVWriteRAMDAC(dev, head, 0x680c1c, 1 << 20);
104 NVWriteRAMDAC(dev, head, 0x680c14, 4 << 16);
107 NVWriteRAMDAC(dev, head, 0x680c6c, testval >> 10 & 0x3ff);
113 NVWriteRAMDAC(dev, head, 0x680c6c, testval & 0x3ff);
119 NVWriteRAMDAC(dev, head, 0x680c1c, ctv_1c);
120 NVWriteRAMDAC(dev, head, 0x680c14, ctv_14);
121 NVWriteRAMDAC(dev, head, 0x680c6c, ctv_6c);
141 if (nv_device_match(device, 0x0322, 0x19da, 0x1035) ||
142 nv_device_match(device, 0x0322, 0x19da, 0x2035)) {
148 if (nv_device_match(device, 0x01f0, 0x1462, 0x5710)) {
164 bool reliable = get_tv_detect_quirks(dev, &tv_enc->
pin_mask);
170 if (nv_device(drm->
device)->chipset == 0x42 ||
171 nv_device(drm->
device)->chipset == 0x43)
173 nv42_tv_sample_load(encoder) >> 28 & 0xe;
188 if (dcb->
tvconf.has_component_output)
205 NV_INFO(drm,
"Load detected on output %c\n",
213 static int nv17_tv_get_ld_modes(
struct drm_encoder *encoder,
243 static int nv17_tv_get_hd_modes(
struct drm_encoder *encoder,
266 if (modes[i].hdisplay > output_mode->
hdisplay ||
267 modes[i].vdisplay > output_mode->
vdisplay)
270 if (modes[i].hdisplay == output_mode->
hdisplay &&
271 modes[i].vdisplay == output_mode->
vdisplay) {
277 modes[i].vdisplay, 60,
false,
278 (output_mode->
flags &
291 if (output_mode->
vdisplay >= 1024) {
305 static int nv17_tv_get_modes(
struct drm_encoder *encoder,
311 return nv17_tv_get_hd_modes(encoder, connector);
313 return nv17_tv_get_ld_modes(encoder, connector);
316 static int nv17_tv_mode_valid(
struct drm_encoder *encoder,
325 if (mode->
clock > 400000)
340 const int vsync_tolerance = 600;
342 if (mode->
clock > 70000)
357 static bool nv17_tv_mode_fixup(
struct drm_encoder *encoder,
369 adjusted_mode->
clock = 90000;
374 static void nv17_tv_dpms(
struct drm_encoder *encoder,
int mode)
386 NV_INFO(drm,
"Setting dpms mode %d on TV encoder (output %d)\n",
409 static void nv17_tv_prepare(
struct drm_encoder *encoder)
439 drm->
vbios.fp.dual_link);
445 if (tv_norm->
kind == CTV_ENC_MODE)
446 *cr_lcd |= 0x1 | (head ? 0x0 : 0x8);
449 dacclk = (NVReadRAMDAC(dev, 0, dacclk_off) & ~0x30) | 0x1;
451 if (nv_device(drm->
device)->card_type == NV_40)
452 dacclk |= 0x1a << 16;
454 if (tv_norm->
kind == CTV_ENC_MODE) {
467 NVWriteRAMDAC(dev, 0, dacclk_off, dacclk);
470 static void nv17_tv_mode_set(
struct drm_encoder *encoder,
508 if (nv_device(drm->
device)->card_type >= NV_30) {
528 for (i = 0; i < 0x40; i++)
543 for (i = 0; i < 38; i++)
585 static void nv17_tv_commit(
struct drm_encoder *encoder)
603 if (nv_device(drm->
device)->chipset < 0x44)
614 NV_INFO(drm,
"Output %s is running on CRTC %d using output %c\n",
620 static void nv17_tv_save(
struct drm_encoder *encoder)
635 static void nv17_tv_restore(
struct drm_encoder *encoder)
648 static int nv17_tv_create_resources(
struct drm_encoder *encoder,
660 if (nouveau_tv_norm) {
661 for (i = 0; i < num_tv_norms; i++) {
668 if (i == num_tv_norms)
669 NV_WARN(drm,
"Invalid TV norm setting \"%s\"\n",
700 static int nv17_tv_set_property(
struct drm_encoder *encoder,
709 bool modes_changed =
false;
748 modes_changed =
true;
771 crtc->
funcs->set_config(&modeset);
778 static void nv17_tv_destroy(
struct drm_encoder *encoder)
787 .dpms = nv17_tv_dpms,
788 .save = nv17_tv_save,
789 .restore = nv17_tv_restore,
790 .mode_fixup = nv17_tv_mode_fixup,
791 .prepare = nv17_tv_prepare,
792 .commit = nv17_tv_commit,
793 .mode_set = nv17_tv_mode_set,
794 .detect = nv17_tv_detect,
798 .get_modes = nv17_tv_get_modes,
799 .mode_valid = nv17_tv_mode_valid,
800 .create_resources = nv17_tv_create_resources,
801 .set_property = nv17_tv_set_property,
805 .destroy = nv17_tv_destroy,
815 tv_enc = kzalloc(
sizeof(*tv_enc),
GFP_KERNEL);
828 encoder = to_drm_encoder(&tv_enc->
base);
834 drm_encoder_helper_add(encoder, &nv17_tv_helper_funcs);
840 nv17_tv_create_resources(encoder, connector);