47 static int nouveau_tv_disable = 0;
51 static int nouveau_ignorelid = 0;
55 static int nouveau_duallink = 1;
58 static void nouveau_connector_hotplug(
void *,
int);
92 if (drm_connector->
encoder == to_drm_encoder(encoder))
110 dev = nv_connector->
base.dev;
116 gpio->
isr_del(gpio, 0, nv_connector->
hpd, 0xff,
117 nouveau_connector_hotplug, connector);
127 nouveau_connector_ddc_detect(
struct drm_connector *connector,
150 if (nv_encoder->
dcb->i2c_index < 0xf)
151 port = i2c->
find(i2c, nv_encoder->
dcb->i2c_index);
153 *pnv_encoder = nv_encoder;
168 struct device_node *cn, *
dn = pci_device_to_OF_node(dev->pdev);
178 int idx = name ? name[
strlen(name) - 1] -
'A' : 0;
180 if (nv_encoder->
dcb->i2c_index == idx && edid) {
192 nouveau_connector_set_encoder(
struct drm_connector *connector,
203 if (nv_device(drm->
device)->card_type >= NV_50) {
213 if (nv_device(drm->
device)->card_type == NV_20 ||
214 (nv_device(drm->
device)->card_type == NV_10 &&
215 (dev->pci_device & 0x0ff0) != 0x0100 &&
216 (dev->pci_device & 0x0ff0) != 0x0150))
225 dev->mode_config.dvi_i_subconnector_property,
244 if (nv_connector->
edid) {
250 i2c = nouveau_connector_ddc_detect(connector, &nv_encoder);
255 if (!nv_connector->
edid) {
256 NV_ERROR(drm,
"DDC responded, but no EDID for %s\n",
263 NV_ERROR(drm,
"Detected %s, but failed init\n",
291 nouveau_connector_set_encoder(connector, nv_encoder);
295 nv_encoder = nouveau_connector_of_detect(connector);
297 nouveau_connector_set_encoder(connector, nv_encoder);
303 if (!nv_encoder && !nouveau_tv_disable)
305 if (nv_encoder && force) {
306 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
310 if (helper->
detect(encoder, connector) ==
312 nouveau_connector_set_encoder(connector, nv_encoder);
322 nouveau_connector_detect_lvds(
struct drm_connector *connector,
bool force)
331 if (nv_connector->
edid) {
342 if (!drm->
vbios.fp_no_ddc) {
343 status = nouveau_connector_detect(connector, force);
357 if (nv_encoder->
dcb->lvdsconf.use_acpi_for_edid) {
369 nv_encoder->
dcb->lvdsconf.use_straps_for_mode)) {
377 if (!drm->
vbios.fp_no_ddc) {
382 *(nv_connector->
edid) = *edid;
388 #if defined(CONFIG_ACPI_BUTTON) || \
389 (defined(CONFIG_ACPI_BUTTON_MODULE) && defined(MODULE))
396 nouveau_connector_set_encoder(connector, nv_encoder);
418 NV_ERROR(drm,
"can't find encoder to force %s on!\n",
424 nouveau_connector_set_encoder(connector, nv_encoder);
428 nouveau_connector_set_property(
struct drm_connector *connector,
434 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
444 if (property == dev->mode_config.scaling_mode_property) {
445 bool modeset =
false;
496 return nv_crtc->
set_scale(nv_crtc,
true);
508 return nv_crtc->
set_scale(nv_crtc,
true);
520 return nv_crtc->
set_scale(nv_crtc,
true);
557 return get_slave_funcs(encoder)->set_property(
558 encoder, connector, property, value);
564 nouveau_connector_native_mode(
struct drm_connector *connector)
571 int high_w = 0, high_h = 0, high_v = 0;
581 NV_DEBUG(drm,
"native mode from preferred\n");
604 NV_DEBUG(drm,
"native mode from largest: %dx%d@%d\n",
605 high_w, high_h, high_v);
614 static struct moderec scaler_modes[] = {
633 nouveau_connector_scaler_modes_add(
struct drm_connector *connector)
638 struct moderec *mode = &scaler_modes[0];
666 nouveau_connector_detect_depth(
struct drm_connector *connector)
695 if (bios->
fp.if_is_24bit)
703 if (nv_connector->
edid &&
705 duallink = ((
u8 *)nv_connector->
edid)[121] == 2;
707 duallink = mode->
clock >= bios->
fp.duallink_transition_clk;
709 if ((!duallink && (bios->
fp.strapless_is_24bit & 1)) ||
710 ( duallink && (bios->
fp.strapless_is_24bit & 2)))
721 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
731 if (nv_connector->
edid)
735 (nv_encoder->
dcb->lvdsconf.use_straps_for_mode ||
747 nouveau_connector_detect_depth(connector);
755 nouveau_connector_native_mode(connector);
769 nouveau_connector_detect_depth(connector);
772 ret = get_slave_funcs(encoder)->get_modes(encoder, connector);
777 ret += nouveau_connector_scaler_modes_add(connector);
790 nv_device(drm->
device)->chipset >= 0x46)
792 else if (nv_device(drm->
device)->chipset >= 0x40)
794 else if (nv_device(drm->
device)->chipset >= 0x18)
801 nouveau_connector_mode_valid(
struct drm_connector *connector,
806 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
807 unsigned min_clock = 25000, max_clock = min_clock;
810 switch (nv_encoder->
dcb->type) {
821 max_clock = get_tmds_link_bandwidth(connector);
822 if (nouveau_duallink && nv_encoder->
dcb->duallink_possible)
826 max_clock = nv_encoder->
dcb->crtconf.maxfreq;
831 return get_slave_funcs(encoder)->mode_valid(encoder, mode);
833 max_clock = nv_encoder->
dp.link_nr;
834 max_clock *= nv_encoder->
dp.link_bw;
842 if (clock < min_clock)
845 if (clock > max_clock)
852 nouveau_connector_best_encoder(
struct drm_connector *connector)
863 nouveau_connector_helper_funcs = {
864 .get_modes = nouveau_connector_get_modes,
865 .mode_valid = nouveau_connector_mode_valid,
866 .best_encoder = nouveau_connector_best_encoder,
870 nouveau_connector_funcs = {
874 .detect = nouveau_connector_detect,
875 .destroy = nouveau_connector_destroy,
877 .set_property = nouveau_connector_set_property,
878 .force = nouveau_connector_force
882 nouveau_connector_funcs_lvds = {
886 .detect = nouveau_connector_detect_lvds,
887 .destroy = nouveau_connector_destroy,
889 .set_property = nouveau_connector_set_property,
890 .force = nouveau_connector_force
936 if (nv_connector->
index == index)
940 nv_connector = kzalloc(
sizeof(*nv_connector),
GFP_KERNEL);
944 connector = &nv_connector->
base;
949 if (nv_connector->
dcb) {
950 static const u8 hpd[16] = {
951 0xff, 0x07, 0x08, 0xff, 0xff, 0x51, 0x52, 0xff,
952 0xff, 0xff, 0xff, 0xff, 0xff, 0x5e, 0x5f, 0x60,
959 nv_connector->
hpd =
ffs((entry & 0x07033000) >> 12);
960 nv_connector->
hpd = hpd[nv_connector->
hpd];
962 nv_connector->
type = nv_connector->
dcb[0];
963 if (drm_conntype_from_dcb(nv_connector->
type) ==
965 NV_WARN(drm,
"unknown connector type %02x\n",
971 if (nv_match_device(dev, 0x0421, 0x1458, 0x344c)) {
977 if (nv_match_device(dev, 0x0402, 0x1458, 0x3455)) {
995 for (i = 0; i < dcbt->
entries; i++) {
996 if (dcbt->
entry[i].connector == nv_connector->
index)
997 encoders |= (1 << dcbt->
entry[
i].type);
1023 type = drm_conntype_from_dcb(nv_connector->
type);
1027 NV_ERROR(drm,
"Error parsing LVDS table, disabling\n");
1028 kfree(nv_connector);
1029 return ERR_PTR(ret);
1032 funcs = &nouveau_connector_funcs_lvds;
1034 funcs = &nouveau_connector_funcs;
1042 drm_connector_helper_add(connector, &nouveau_connector_helper_funcs);
1075 switch (nv_connector->
type) {
1077 if (nv_device(drm->
device)->card_type >= NV_50) {
1079 dev->mode_config.scaling_mode_property,
1092 dev->mode_config.scaling_mode_property,
1111 ret = gpio->
isr_add(gpio, 0, nv_connector->
hpd, 0xff,
1112 nouveau_connector_hotplug, connector);
1122 nouveau_connector_hotplug(
void *
data,
int plugged)
1128 NV_DEBUG(drm,
"%splugged %s\n", plugged ?
"" :
"un",