aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2009-12-17 12:52:44 -0500
committerDave Airlie <airlied@redhat.com>2010-01-10 23:41:08 -0500
commit02076da97a15bbf7477bffed71d02f726de2afc2 (patch)
treec4b4716068789f8114e9ed88a47bf34251568514 /drivers/gpu
parente55ca7e68efc7c2d320cd9975ebc5e0fd27debf0 (diff)
drm/nouveau: Clean up the nv17-nv4x load detection code a bit.
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h6
-rw-r--r--drivers/gpu/drm/nouveau/nv04_dac.c35
-rw-r--r--drivers/gpu/drm/nouveau/nv17_tv.c27
3 files changed, 37 insertions, 31 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 9c9815bf505a..7da88a92c83f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -1074,8 +1074,7 @@ extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd,
1074 1074
1075/* nv04_dac.c */ 1075/* nv04_dac.c */
1076extern int nv04_dac_create(struct drm_device *dev, struct dcb_entry *entry); 1076extern int nv04_dac_create(struct drm_device *dev, struct dcb_entry *entry);
1077extern enum drm_connector_status nv17_dac_detect(struct drm_encoder *encoder, 1077extern uint32_t nv17_dac_sample_load(struct drm_encoder *encoder);
1078 struct drm_connector *connector);
1079extern int nv04_dac_output_offset(struct drm_encoder *encoder); 1078extern int nv04_dac_output_offset(struct drm_encoder *encoder);
1080extern void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable); 1079extern void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable);
1081 1080
@@ -1093,9 +1092,6 @@ extern int nv04_tv_create(struct drm_device *dev, struct dcb_entry *entry);
1093 1092
1094/* nv17_tv.c */ 1093/* nv17_tv.c */
1095extern int nv17_tv_create(struct drm_device *dev, struct dcb_entry *entry); 1094extern int nv17_tv_create(struct drm_device *dev, struct dcb_entry *entry);
1096extern enum drm_connector_status nv17_tv_detect(struct drm_encoder *encoder,
1097 struct drm_connector *connector,
1098 uint32_t pin_mask);
1099 1095
1100/* nv04_display.c */ 1096/* nv04_display.c */
1101extern int nv04_display_create(struct drm_device *); 1097extern int nv04_display_create(struct drm_device *);
diff --git a/drivers/gpu/drm/nouveau/nv04_dac.c b/drivers/gpu/drm/nouveau/nv04_dac.c
index d9f32879ba38..d0e038d28948 100644
--- a/drivers/gpu/drm/nouveau/nv04_dac.c
+++ b/drivers/gpu/drm/nouveau/nv04_dac.c
@@ -212,16 +212,15 @@ out:
212 return connector_status_disconnected; 212 return connector_status_disconnected;
213} 213}
214 214
215enum drm_connector_status nv17_dac_detect(struct drm_encoder *encoder, 215uint32_t nv17_dac_sample_load(struct drm_encoder *encoder)
216 struct drm_connector *connector)
217{ 216{
218 struct drm_device *dev = encoder->dev; 217 struct drm_device *dev = encoder->dev;
219 struct drm_nouveau_private *dev_priv = dev->dev_private; 218 struct drm_nouveau_private *dev_priv = dev->dev_private;
220 struct dcb_entry *dcb = nouveau_encoder(encoder)->dcb; 219 struct dcb_entry *dcb = nouveau_encoder(encoder)->dcb;
221 uint32_t testval, regoffset = nv04_dac_output_offset(encoder); 220 uint32_t sample, testval, regoffset = nv04_dac_output_offset(encoder);
222 uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput, 221 uint32_t saved_powerctrl_2 = 0, saved_powerctrl_4 = 0, saved_routput,
223 saved_rtest_ctrl, saved_gpio0, saved_gpio1, temp, routput; 222 saved_rtest_ctrl, saved_gpio0, saved_gpio1, temp, routput;
224 int head, present = 0; 223 int head;
225 224
226#define RGB_TEST_DATA(r, g, b) (r << 0 | g << 10 | b << 20) 225#define RGB_TEST_DATA(r, g, b) (r << 0 | g << 10 | b << 20)
227 if (dcb->type == OUTPUT_TV) { 226 if (dcb->type == OUTPUT_TV) {
@@ -287,13 +286,7 @@ enum drm_connector_status nv17_dac_detect(struct drm_encoder *encoder,
287 temp | NV_PRAMDAC_TEST_CONTROL_TP_INS_EN_ASSERTED); 286 temp | NV_PRAMDAC_TEST_CONTROL_TP_INS_EN_ASSERTED);
288 msleep(5); 287 msleep(5);
289 288
290 temp = NVReadRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset); 289 sample = NVReadRAMDAC(dev, 0, NV_PRAMDAC_TEST_CONTROL + regoffset);
291
292 if (dcb->type == OUTPUT_TV)
293 present = (nv17_tv_detect(encoder, connector, temp)
294 == connector_status_connected);
295 else
296 present = temp & NV_PRAMDAC_TEST_CONTROL_SENSEB_ALLHI;
297 290
298 temp = NVReadRAMDAC(dev, head, NV_PRAMDAC_TEST_CONTROL); 291 temp = NVReadRAMDAC(dev, head, NV_PRAMDAC_TEST_CONTROL);
299 NVWriteRAMDAC(dev, head, NV_PRAMDAC_TEST_CONTROL, 292 NVWriteRAMDAC(dev, head, NV_PRAMDAC_TEST_CONTROL,
@@ -310,15 +303,25 @@ enum drm_connector_status nv17_dac_detect(struct drm_encoder *encoder,
310 nv17_gpio_set(dev, DCB_GPIO_TVDAC1, saved_gpio1); 303 nv17_gpio_set(dev, DCB_GPIO_TVDAC1, saved_gpio1);
311 nv17_gpio_set(dev, DCB_GPIO_TVDAC0, saved_gpio0); 304 nv17_gpio_set(dev, DCB_GPIO_TVDAC0, saved_gpio0);
312 305
313 if (present) { 306 return sample;
314 NV_INFO(dev, "Load detected on output %c\n", '@' + ffs(dcb->or)); 307}
308
309static enum drm_connector_status
310nv17_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
311{
312 struct drm_device *dev = encoder->dev;
313 struct dcb_entry *dcb = nouveau_encoder(encoder)->dcb;
314 uint32_t sample = nv17_dac_sample_load(encoder);
315
316 if (sample & NV_PRAMDAC_TEST_CONTROL_SENSEB_ALLHI) {
317 NV_INFO(dev, "Load detected on output %c\n",
318 '@' + ffs(dcb->or));
315 return connector_status_connected; 319 return connector_status_connected;
320 } else {
321 return connector_status_disconnected;
316 } 322 }
317
318 return connector_status_disconnected;
319} 323}
320 324
321
322static bool nv04_dac_mode_fixup(struct drm_encoder *encoder, 325static bool nv04_dac_mode_fixup(struct drm_encoder *encoder,
323 struct drm_display_mode *mode, 326 struct drm_display_mode *mode,
324 struct drm_display_mode *adjusted_mode) 327 struct drm_display_mode *adjusted_mode)
diff --git a/drivers/gpu/drm/nouveau/nv17_tv.c b/drivers/gpu/drm/nouveau/nv17_tv.c
index 81c01353a9f9..5fa4242e4c7d 100644
--- a/drivers/gpu/drm/nouveau/nv17_tv.c
+++ b/drivers/gpu/drm/nouveau/nv17_tv.c
@@ -33,13 +33,15 @@
33#include "nouveau_hw.h" 33#include "nouveau_hw.h"
34#include "nv17_tv.h" 34#include "nv17_tv.h"
35 35
36enum drm_connector_status nv17_tv_detect(struct drm_encoder *encoder, 36static enum drm_connector_status
37 struct drm_connector *connector, 37nv17_tv_detect(struct drm_encoder *encoder, struct drm_connector *connector)
38 uint32_t pin_mask)
39{ 38{
39 struct drm_device *dev = encoder->dev;
40 struct drm_mode_config *conf = &dev->mode_config;
40 struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder); 41 struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder);
42 struct dcb_entry *dcb = tv_enc->base.dcb;
41 43
42 tv_enc->pin_mask = pin_mask >> 28 & 0xe; 44 tv_enc->pin_mask = nv17_dac_sample_load(encoder) >> 28 & 0xe;
43 45
44 switch (tv_enc->pin_mask) { 46 switch (tv_enc->pin_mask) {
45 case 0x2: 47 case 0x2:
@@ -50,7 +52,7 @@ enum drm_connector_status nv17_tv_detect(struct drm_encoder *encoder,
50 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_SVIDEO; 52 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_SVIDEO;
51 break; 53 break;
52 case 0xe: 54 case 0xe:
53 if (nouveau_encoder(encoder)->dcb->tvconf.has_component_output) 55 if (dcb->tvconf.has_component_output)
54 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_Component; 56 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_Component;
55 else 57 else
56 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_SCART; 58 tv_enc->subconnector = DRM_MODE_SUBCONNECTOR_SCART;
@@ -61,11 +63,16 @@ enum drm_connector_status nv17_tv_detect(struct drm_encoder *encoder,
61 } 63 }
62 64
63 drm_connector_property_set_value(connector, 65 drm_connector_property_set_value(connector,
64 encoder->dev->mode_config.tv_subconnector_property, 66 conf->tv_subconnector_property,
65 tv_enc->subconnector); 67 tv_enc->subconnector);
66 68
67 return tv_enc->subconnector ? connector_status_connected : 69 if (tv_enc->subconnector) {
68 connector_status_disconnected; 70 NV_INFO(dev, "Load detected on output %c\n",
71 '@' + ffs(dcb->or));
72 return connector_status_connected;
73 } else {
74 return connector_status_disconnected;
75 }
69} 76}
70 77
71static const struct { 78static const struct {
@@ -633,7 +640,7 @@ static struct drm_encoder_helper_funcs nv17_tv_helper_funcs = {
633 .prepare = nv17_tv_prepare, 640 .prepare = nv17_tv_prepare,
634 .commit = nv17_tv_commit, 641 .commit = nv17_tv_commit,
635 .mode_set = nv17_tv_mode_set, 642 .mode_set = nv17_tv_mode_set,
636 .detect = nv17_dac_detect, 643 .detect = nv17_tv_detect,
637}; 644};
638 645
639static struct drm_encoder_slave_funcs nv17_tv_slave_funcs = { 646static struct drm_encoder_slave_funcs nv17_tv_slave_funcs = {