Subversion Repositories Kolibri OS

Rev

Rev 2340 | Rev 3031 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2340 Rev 2342
Line 56... Line 56...
56
 
56
 
57
#define IS_TV(c)    (c->output_flag & SDVO_TV_MASK)
57
#define IS_TV(c)    (c->output_flag & SDVO_TV_MASK)
58
#define IS_TMDS(c)  (c->output_flag & SDVO_TMDS_MASK)
58
#define IS_TMDS(c)  (c->output_flag & SDVO_TMDS_MASK)
59
#define IS_LVDS(c)  (c->output_flag & SDVO_LVDS_MASK)
59
#define IS_LVDS(c)  (c->output_flag & SDVO_LVDS_MASK)
-
 
60
#define IS_TV_OR_LVDS(c) (c->output_flag & (SDVO_TV_MASK | SDVO_LVDS_MASK))
Line 60... Line 61...
60
#define IS_TV_OR_LVDS(c) (c->output_flag & (SDVO_TV_MASK | SDVO_LVDS_MASK))
61
#define IS_DIGITAL(c) (c->output_flag & (SDVO_TMDS_MASK | SDVO_LVDS_MASK))
61
 
62
 
62
 
63
 
Line 99... Line 100...
99
    * For multiple function SDVO device,
100
    * For multiple function SDVO device,
100
    * this is for current attached outputs.
101
    * this is for current attached outputs.
101
    */
102
    */
102
    uint16_t attached_output;
103
    uint16_t attached_output;
Line -... Line 104...
-
 
104
 
-
 
105
	/*
-
 
106
	 * Hotplug activation bits for this device
-
 
107
	 */
-
 
108
	uint8_t hotplug_active[2];
103
 
109
 
104
    /**
110
    /**
105
     * This is used to select the color range of RBG outputs in HDMI mode.
111
     * This is used to select the color range of RBG outputs in HDMI mode.
106
     * It is only valid when using TMDS encoding and 8 bit per color mode.
112
     * It is only valid when using TMDS encoding and 8 bit per color mode.
107
     */
113
     */
Line 1066... Line 1072...
1066
	if (!intel_sdvo_set_clock_rate_mult(intel_sdvo, rate))
1072
	if (!intel_sdvo_set_clock_rate_mult(intel_sdvo, rate))
1067
		return;
1073
		return;
Line 1068... Line 1074...
1068
 
1074
 
1069
	/* Set the SDVO control regs. */
1075
	/* Set the SDVO control regs. */
-
 
1076
	if (INTEL_INFO(dev)->gen >= 4) {
1070
	if (INTEL_INFO(dev)->gen >= 4) {
1077
		/* The real mode polarity is set by the SDVO commands, using
-
 
1078
		 * struct intel_sdvo_dtd. */
1071
		sdvox = 0;
1079
		sdvox = SDVO_VSYNC_ACTIVE_HIGH | SDVO_HSYNC_ACTIVE_HIGH;
1072
		if (intel_sdvo->is_hdmi)
1080
		if (intel_sdvo->is_hdmi)
1073
			sdvox |= intel_sdvo->color_range;
1081
			sdvox |= intel_sdvo->color_range;
1074
		if (INTEL_INFO(dev)->gen < 5)
1082
		if (INTEL_INFO(dev)->gen < 5)
1075
			sdvox |= SDVO_BORDER_ENABLE;
-
 
1076
		if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
-
 
1077
			sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
-
 
1078
		if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
-
 
1079
			sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
1083
			sdvox |= SDVO_BORDER_ENABLE;
1080
	} else {
1084
	} else {
1081
		sdvox = I915_READ(intel_sdvo->sdvo_reg);
1085
		sdvox = I915_READ(intel_sdvo->sdvo_reg);
1082
		switch (intel_sdvo->sdvo_reg) {
1086
		switch (intel_sdvo->sdvo_reg) {
1083
		case SDVOB:
1087
		case SDVOB:
Line 1087... Line 1091...
1087
			sdvox &= SDVOC_PRESERVE_MASK;
1091
			sdvox &= SDVOC_PRESERVE_MASK;
1088
			break;
1092
			break;
1089
		}
1093
		}
1090
		sdvox |= (9 << 19) | SDVO_BORDER_ENABLE;
1094
		sdvox |= (9 << 19) | SDVO_BORDER_ENABLE;
1091
	}
1095
	}
-
 
1096
 
1092
	if (intel_crtc->pipe == 1)
1097
	if (INTEL_PCH_TYPE(dev) >= PCH_CPT)
-
 
1098
		sdvox |= TRANSCODER_CPT(intel_crtc->pipe);
-
 
1099
	else
1093
		sdvox |= SDVO_PIPE_B_SELECT;
1100
		sdvox |= TRANSCODER(intel_crtc->pipe);
-
 
1101
 
1094
	if (intel_sdvo->has_hdmi_audio)
1102
	if (intel_sdvo->has_hdmi_audio)
1095
		sdvox |= SDVO_AUDIO_ENABLE;
1103
		sdvox |= SDVO_AUDIO_ENABLE;
Line 1096... Line 1104...
1096
 
1104
 
1097
	if (INTEL_INFO(dev)->gen >= 4) {
1105
	if (INTEL_INFO(dev)->gen >= 4) {
Line 1215... Line 1223...
1215
		      caps->output_flags);
1223
		      caps->output_flags);
Line 1216... Line 1224...
1216
 
1224
 
1217
	return true;
1225
	return true;
Line 1218... Line -...
1218
}
-
 
1219
 
-
 
1220
/* No use! */
-
 
1221
#if 0
-
 
1222
struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB)
-
 
1223
{
-
 
1224
	struct drm_connector *connector = NULL;
-
 
1225
	struct intel_sdvo *iout = NULL;
-
 
1226
	struct intel_sdvo *sdvo;
-
 
1227
 
-
 
1228
	/* find the sdvo connector */
-
 
1229
	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-
 
1230
		iout = to_intel_sdvo(connector);
-
 
1231
 
-
 
1232
		if (iout->type != INTEL_OUTPUT_SDVO)
-
 
1233
			continue;
-
 
1234
 
-
 
1235
		sdvo = iout->dev_priv;
-
 
1236
 
-
 
1237
		if (sdvo->sdvo_reg == SDVOB && sdvoB)
-
 
1238
			return connector;
-
 
1239
 
-
 
1240
		if (sdvo->sdvo_reg == SDVOC && !sdvoB)
-
 
1241
			return connector;
-
 
1242
 
-
 
1243
	}
-
 
1244
 
-
 
1245
	return NULL;
-
 
1246
}
1226
}
1247
 
1227
 
1248
int intel_sdvo_supports_hotplug(struct drm_connector *connector)
1228
static int intel_sdvo_supports_hotplug(struct intel_sdvo *intel_sdvo)
1249
{
-
 
1250
	u8 response[2];
-
 
1251
	u8 status;
-
 
1252
	struct intel_sdvo *intel_sdvo;
-
 
1253
	DRM_DEBUG_KMS("\n");
-
 
1254
 
-
 
1255
	if (!connector)
-
 
1256
		return 0;
-
 
Line 1257... Line 1229...
1257
 
1229
{
1258
	intel_sdvo = to_intel_sdvo(connector);
1230
	u8 response[2];
1259
 
1231
 
Line 1260... Line 1232...
1260
	return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
1232
	return intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT,
1261
				    &response, 2) && response[0];
1233
				    &response, 2) && response[0];
1262
}
-
 
1263
 
-
 
1264
void intel_sdvo_set_hotplug(struct drm_connector *connector, int on)
1234
}
1265
{
-
 
1266
	u8 response[2];
-
 
1267
	u8 status;
-
 
1268
	struct intel_sdvo *intel_sdvo = to_intel_sdvo(connector);
-
 
1269
 
-
 
1270
	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
-
 
1271
	intel_sdvo_read_response(intel_sdvo, &response, 2);
-
 
Line 1272... Line -...
1272
 
-
 
1273
	if (on) {
-
 
1274
		intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
-
 
1275
		status = intel_sdvo_read_response(intel_sdvo, &response, 2);
-
 
1276
 
1235
 
1277
		intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
-
 
1278
	} else {
-
 
1279
		response[0] = 0;
-
 
1280
		response[1] = 0;
-
 
1281
		intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
1236
static void intel_sdvo_enable_hotplug(struct intel_encoder *encoder)
1282
	}
-
 
Line 1283... Line 1237...
1283
 
1237
{
1284
	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
1238
	struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
1285
	intel_sdvo_read_response(intel_sdvo, &response, 2);
1239
 
1286
}
1240
	intel_sdvo_write_cmd(intel_sdvo, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &intel_sdvo->hotplug_active, 2);
1287
#endif
1241
}
1288
 
-
 
1289
static bool
1242
 
Line 1290... Line 1243...
1290
intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
1243
static bool
1291
{
1244
intel_sdvo_multifunc_encoder(struct intel_sdvo *intel_sdvo)
1292
	/* Is there more than one type of output? */
1245
{
Line 1310... Line 1263...
1310
	return drm_get_edid(connector,
1263
	return drm_get_edid(connector,
1311
			    &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
1264
			    &dev_priv->gmbus[dev_priv->crt_ddc_pin].adapter);
1312
}
1265
}
Line 1313... Line 1266...
1313
 
1266
 
1314
enum drm_connector_status
1267
enum drm_connector_status
1315
intel_sdvo_hdmi_sink_detect(struct drm_connector *connector)
1268
intel_sdvo_tmds_sink_detect(struct drm_connector *connector)
1316
{
1269
{
1317
	struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1270
	struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
1318
	enum drm_connector_status status;
1271
	enum drm_connector_status status;
Line 1370... Line 1323...
1370
	}
1323
	}
Line 1371... Line 1324...
1371
 
1324
 
1372
	return status;
1325
	return status;
Line -... Line 1326...
-
 
1326
}
-
 
1327
 
-
 
1328
static bool
-
 
1329
intel_sdvo_connector_matches_edid(struct intel_sdvo_connector *sdvo,
-
 
1330
				  struct edid *edid)
-
 
1331
{
-
 
1332
	bool monitor_is_digital = !!(edid->input & DRM_EDID_INPUT_DIGITAL);
-
 
1333
	bool connector_is_digital = !!IS_DIGITAL(sdvo);
-
 
1334
 
-
 
1335
	DRM_DEBUG_KMS("connector_is_digital? %d, monitor_is_digital? %d\n",
-
 
1336
		      connector_is_digital, monitor_is_digital);
-
 
1337
	return connector_is_digital == monitor_is_digital;
1373
}
1338
}
1374
 
1339
 
1375
static enum drm_connector_status
1340
static enum drm_connector_status
1376
intel_sdvo_detect(struct drm_connector *connector, bool force)
1341
intel_sdvo_detect(struct drm_connector *connector, bool force)
1377
{
1342
{
Line 1405... Line 1370...
1405
	intel_sdvo->has_hdmi_audio = false;
1370
	intel_sdvo->has_hdmi_audio = false;
Line 1406... Line 1371...
1406
 
1371
 
1407
	if ((intel_sdvo_connector->output_flag & response) == 0)
1372
	if ((intel_sdvo_connector->output_flag & response) == 0)
1408
		ret = connector_status_disconnected;
1373
		ret = connector_status_disconnected;
1409
	else if (IS_TMDS(intel_sdvo_connector))
1374
	else if (IS_TMDS(intel_sdvo_connector))
1410
		ret = intel_sdvo_hdmi_sink_detect(connector);
1375
		ret = intel_sdvo_tmds_sink_detect(connector);
1411
	else {
1376
	else {
Line 1412... Line 1377...
1412
		struct edid *edid;
1377
		struct edid *edid;
1413
 
1378
 
1414
		/* if we have an edid check it matches the connection */
1379
		/* if we have an edid check it matches the connection */
1415
		edid = intel_sdvo_get_edid(connector);
1380
		edid = intel_sdvo_get_edid(connector);
1416
		if (edid == NULL)
1381
		if (edid == NULL)
1417
			edid = intel_sdvo_get_analog_edid(connector);
-
 
1418
		if (edid != NULL) {
1382
			edid = intel_sdvo_get_analog_edid(connector);
1419
			if (edid->input & DRM_EDID_INPUT_DIGITAL)
1383
		if (edid != NULL) {
1420
				ret = connector_status_disconnected;
1384
			if (intel_sdvo_connector_matches_edid(intel_sdvo_connector,
-
 
1385
							      edid))
-
 
1386
				ret = connector_status_connected;
-
 
1387
			else
1421
			else
1388
				ret = connector_status_disconnected;
1422
				ret = connector_status_connected;
1389
 
1423
			connector->display_info.raw_edid = NULL;
1390
			connector->display_info.raw_edid = NULL;
1424
			kfree(edid);
1391
			kfree(edid);
1425
		} else
1392
		} else
Line 1458... Line 1425...
1458
	 */
1425
	 */
1459
	if (edid == NULL)
1426
	if (edid == NULL)
1460
		edid = intel_sdvo_get_analog_edid(connector);
1427
		edid = intel_sdvo_get_analog_edid(connector);
Line 1461... Line 1428...
1461
 
1428
 
1462
	if (edid != NULL) {
1429
	if (edid != NULL) {
1463
		struct intel_sdvo_connector *intel_sdvo_connector = to_intel_sdvo_connector(connector);
-
 
1464
		bool monitor_is_digital = !!(edid->input & DRM_EDID_INPUT_DIGITAL);
-
 
1465
		bool connector_is_digital = !!IS_TMDS(intel_sdvo_connector);
-
 
1466
 
1430
		if (intel_sdvo_connector_matches_edid(to_intel_sdvo_connector(connector),
1467
		if (connector_is_digital == monitor_is_digital) {
1431
						      edid)) {
1468
			drm_mode_connector_update_edid_property(connector, edid);
1432
			drm_mode_connector_update_edid_property(connector, edid);
1469
			drm_add_edid_modes(connector, edid);
1433
			drm_add_edid_modes(connector, edid);
Line 1470... Line 1434...
1470
		}
1434
		}
Line 1942... Line 1906...
1942
static void
1906
static void
1943
intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
1907
intel_sdvo_select_i2c_bus(struct drm_i915_private *dev_priv,
1944
			  struct intel_sdvo *sdvo, u32 reg)
1908
			  struct intel_sdvo *sdvo, u32 reg)
1945
{
1909
{
1946
	struct sdvo_device_mapping *mapping;
1910
	struct sdvo_device_mapping *mapping;
1947
	u8 pin, speed;
1911
	u8 pin;
Line 1948... Line 1912...
1948
 
1912
 
1949
	if (IS_SDVOB(reg))
1913
	if (IS_SDVOB(reg))
1950
		mapping = &dev_priv->sdvo_mappings[0];
1914
		mapping = &dev_priv->sdvo_mappings[0];
1951
	else
1915
	else
Line 1952... Line 1916...
1952
		mapping = &dev_priv->sdvo_mappings[1];
1916
		mapping = &dev_priv->sdvo_mappings[1];
1953
 
-
 
1954
	pin = GMBUS_PORT_DPB;
1917
 
1955
	speed = GMBUS_RATE_1MHZ >> 8;
1918
	pin = GMBUS_PORT_DPB;
1956
	if (mapping->initialized) {
-
 
1957
		pin = mapping->i2c_pin;
-
 
Line 1958... Line 1919...
1958
		speed = mapping->i2c_speed;
1919
	if (mapping->initialized)
1959
	}
1920
		pin = mapping->i2c_pin;
1960
 
1921
 
1961
	if (pin < GMBUS_NUM_PORTS) {
1922
	if (pin < GMBUS_NUM_PORTS) {
1962
		sdvo->i2c = &dev_priv->gmbus[pin].adapter;
1923
		sdvo->i2c = &dev_priv->gmbus[pin].adapter;
1963
		intel_gmbus_set_speed(sdvo->i2c, speed);
1924
		intel_gmbus_set_speed(sdvo->i2c, GMBUS_RATE_1MHZ);
1964
		intel_gmbus_force_bit(sdvo->i2c, true);
1925
		intel_gmbus_force_bit(sdvo->i2c, true);
-
 
1926
	} else {
Line 1965... Line 1927...
1965
	} else
1927
		sdvo->i2c = &dev_priv->gmbus[GMBUS_PORT_DPB].adapter;
1966
		sdvo->i2c = &dev_priv->gmbus[GMBUS_PORT_DPB].adapter;
1928
	}
1967
}
1929
}
1968
 
1930
 
Line 2042... Line 2004...
2042
static bool
2004
static bool
2043
intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2005
intel_sdvo_dvi_init(struct intel_sdvo *intel_sdvo, int device)
2044
{
2006
{
2045
	struct drm_encoder *encoder = &intel_sdvo->base.base;
2007
	struct drm_encoder *encoder = &intel_sdvo->base.base;
2046
	struct drm_connector *connector;
2008
	struct drm_connector *connector;
-
 
2009
	struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
2047
	struct intel_connector *intel_connector;
2010
	struct intel_connector *intel_connector;
2048
	struct intel_sdvo_connector *intel_sdvo_connector;
2011
	struct intel_sdvo_connector *intel_sdvo_connector;
Line 2049... Line 2012...
2049
 
2012
 
2050
	intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
2013
	intel_sdvo_connector = kzalloc(sizeof(struct intel_sdvo_connector), GFP_KERNEL);
Line 2059... Line 2022...
2059
		intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS1;
2022
		intel_sdvo_connector->output_flag = SDVO_OUTPUT_TMDS1;
2060
	}
2023
	}
Line 2061... Line 2024...
2061
 
2024
 
2062
	intel_connector = &intel_sdvo_connector->base;
2025
	intel_connector = &intel_sdvo_connector->base;
-
 
2026
	connector = &intel_connector->base;
-
 
2027
	if (intel_sdvo_supports_hotplug(intel_sdvo) & (1 << device)) {
-
 
2028
		connector->polled = DRM_CONNECTOR_POLL_HPD;
-
 
2029
		intel_sdvo->hotplug_active[0] |= 1 << device;
-
 
2030
		/* Some SDVO devices have one-shot hotplug interrupts.
-
 
2031
		 * Ensure that they get re-enabled when an interrupt happens.
-
 
2032
		 */
-
 
2033
		intel_encoder->hot_plug = intel_sdvo_enable_hotplug;
-
 
2034
		intel_sdvo_enable_hotplug(intel_encoder);
-
 
2035
	}
2063
	connector = &intel_connector->base;
2036
	else
2064
	connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
2037
	connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
2065
	encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
2038
	encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
Line 2066... Line 2039...
2066
	connector->connector_type = DRM_MODE_CONNECTOR_DVID;
2039
	connector->connector_type = DRM_MODE_CONNECTOR_DVID;
Line 2241... Line 2214...
2241
		DRM_DEBUG_KMS("%s: Unknown SDVO output type (0x%02x%02x)\n",
2214
		DRM_DEBUG_KMS("%s: Unknown SDVO output type (0x%02x%02x)\n",
2242
			      SDVO_NAME(intel_sdvo),
2215
			      SDVO_NAME(intel_sdvo),
2243
			      bytes[0], bytes[1]);
2216
			      bytes[0], bytes[1]);
2244
		return false;
2217
		return false;
2245
	}
2218
	}
2246
	intel_sdvo->base.crtc_mask = (1 << 0) | (1 << 1);
2219
	intel_sdvo->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
Line 2247... Line 2220...
2247
 
2220
 
2248
	return true;
2221
	return true;
Line 2249... Line 2222...
2249
}
2222
}
Line 2566... Line 2539...
2566
 
2539
 
2567
    /* In default case sdvo lvds is false */
2540
    /* In default case sdvo lvds is false */
2568
    if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
2541
    if (!intel_sdvo_get_capabilities(intel_sdvo, &intel_sdvo->caps))
Line -... Line 2542...
-
 
2542
        goto err;
-
 
2543
 
-
 
2544
	/* Set up hotplug command - note paranoia about contents of reply.
-
 
2545
	 * We assume that the hardware is in a sane state, and only touch
-
 
2546
	 * the bits we think we understand.
-
 
2547
	 */
-
 
2548
	intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_ACTIVE_HOT_PLUG,
-
 
2549
			     &intel_sdvo->hotplug_active, 2);
2569
        goto err;
2550
	intel_sdvo->hotplug_active[0] &= ~0x3;
2570
 
2551
 
2571
    if (intel_sdvo_output_setup(intel_sdvo,
2552
    if (intel_sdvo_output_setup(intel_sdvo,
2572
                    intel_sdvo->caps.output_flags) != true) {
2553
                    intel_sdvo->caps.output_flags) != true) {
2573
        DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
2554
        DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",