Subversion Repositories Kolibri OS

Rev

Rev 5078 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5078 Rev 6104
Line 64... Line 64...
64
		radeon_router_select_ddc_port(radeon_connector);
64
		radeon_router_select_ddc_port(radeon_connector);
Line 65... Line 65...
65
 
65
 
66
	if (use_aux) {
66
	if (use_aux) {
67
		ret = i2c_transfer(&radeon_connector->ddc_bus->aux.ddc, msgs, 2);
67
		ret = i2c_transfer(&radeon_connector->ddc_bus->aux.ddc, msgs, 2);
68
	} else {
68
	} else {
69
	ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
69
		ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
Line 70... Line 70...
70
	}
70
	}
71
 
71
 
72
	if (ret != 2)
72
	if (ret != 2)
73
		/* Couldn't find an accessible DDC on this connector */
73
		/* Couldn't find an accessible DDC on this connector */
74
		return false;
74
		return false;
75
		/* Probe also for valid EDID header
75
	/* Probe also for valid EDID header
76
		 * EDID header starts with:
76
	 * EDID header starts with:
77
		 * 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00.
77
	 * 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00.
78
		 * Only the first 6 bytes must be valid as
78
	 * Only the first 6 bytes must be valid as
79
		 * drm_edid_block_valid() can fix the last 2 bytes */
79
	 * drm_edid_block_valid() can fix the last 2 bytes */
80
		if (drm_edid_header_is_valid(buf) < 6) {
80
	if (drm_edid_header_is_valid(buf) < 6) {
81
			/* Couldn't find an accessible EDID on this
81
		/* Couldn't find an accessible EDID on this
82
			 * connector */
82
		 * connector */
83
			return false;
83
		return false;
84
		}
84
	}
Line 85... Line 85...
85
		return true;
85
	return true;
Line 86... Line 86...
86
}
86
}
Line 99... Line 99...
99
	/* RV410 appears to have a bug where the hw i2c in reset
99
	/* RV410 appears to have a bug where the hw i2c in reset
100
	 * holds the i2c port in a bad state - switch hw i2c away before
100
	 * holds the i2c port in a bad state - switch hw i2c away before
101
	 * doing DDC - do this for all r200s/r300s/r400s for safety sake
101
	 * doing DDC - do this for all r200s/r300s/r400s for safety sake
102
	 */
102
	 */
103
	if (rec->hw_capable) {
103
	if (rec->hw_capable) {
104
	if ((rdev->family >= CHIP_R200) && !ASIC_IS_AVIVO(rdev)) {
104
		if ((rdev->family >= CHIP_R200) && !ASIC_IS_AVIVO(rdev)) {
105
			u32 reg;
105
			u32 reg;
Line 106... Line 106...
106
 
106
 
107
			if (rdev->family >= CHIP_RV350)
107
			if (rdev->family >= CHIP_RV350)
108
				reg = RADEON_GPIO_MONID;
108
				reg = RADEON_GPIO_MONID;
Line 112... Line 112...
112
			else
112
			else
113
				reg = RADEON_GPIO_CRT2_DDC;
113
				reg = RADEON_GPIO_CRT2_DDC;
Line 114... Line 114...
114
 
114
 
115
			mutex_lock(&rdev->dc_hw_i2c_mutex);
115
			mutex_lock(&rdev->dc_hw_i2c_mutex);
116
			if (rec->a_clk_reg == reg) {
116
			if (rec->a_clk_reg == reg) {
117
			WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
117
				WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
118
						R200_DVI_I2C_PIN_SEL(R200_SEL_DDC1)));
118
							       R200_DVI_I2C_PIN_SEL(R200_SEL_DDC1)));
119
		} else {
119
			} else {
120
			WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
120
				WREG32(RADEON_DVI_I2C_CNTL_0, (RADEON_I2C_SOFT_RST |
121
						R200_DVI_I2C_PIN_SEL(R200_SEL_DDC3)));
121
							       R200_DVI_I2C_PIN_SEL(R200_SEL_DDC3)));
122
		}
122
			}
123
			mutex_unlock(&rdev->dc_hw_i2c_mutex);
123
			mutex_unlock(&rdev->dc_hw_i2c_mutex);
124
	}
124
		}
Line 125... Line 125...
125
	}
125
	}
126
 
126
 
127
	/* switch the pads to ddc mode */
127
	/* switch the pads to ddc mode */
Line 131... Line 131...
131
		WREG32(rec->mask_clk_reg, temp);
131
		WREG32(rec->mask_clk_reg, temp);
132
	}
132
	}
Line 133... Line 133...
133
 
133
 
134
	/* clear the output pin values */
134
	/* clear the output pin values */
135
	temp = RREG32(rec->a_clk_reg) & ~rec->a_clk_mask;
135
	temp = RREG32(rec->a_clk_reg) & ~rec->a_clk_mask;
Line 136... Line 136...
136
		WREG32(rec->a_clk_reg, temp);
136
	WREG32(rec->a_clk_reg, temp);
137
 
137
 
Line 138... Line 138...
138
	temp = RREG32(rec->a_data_reg) & ~rec->a_data_mask;
138
	temp = RREG32(rec->a_data_reg) & ~rec->a_data_mask;
139
		WREG32(rec->a_data_reg, temp);
139
	WREG32(rec->a_data_reg, temp);
140
 
140
 
Line 836... Line 836...
836
	case CHIP_R420:
836
	case CHIP_R420:
837
	case CHIP_R423:
837
	case CHIP_R423:
838
	case CHIP_RV410:
838
	case CHIP_RV410:
839
	case CHIP_RS400:
839
	case CHIP_RS400:
840
	case CHIP_RS480:
840
	case CHIP_RS480:
841
			ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
841
		ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
842
		break;
842
		break;
843
	case CHIP_RS600:
843
	case CHIP_RS600:
844
	case CHIP_RS690:
844
	case CHIP_RS690:
845
	case CHIP_RS740:
845
	case CHIP_RS740:
846
		/* XXX fill in hw i2c implementation */
846
		/* XXX fill in hw i2c implementation */
Line 849... Line 849...
849
	case CHIP_R520:
849
	case CHIP_R520:
850
	case CHIP_RV530:
850
	case CHIP_RV530:
851
	case CHIP_RV560:
851
	case CHIP_RV560:
852
	case CHIP_RV570:
852
	case CHIP_RV570:
853
	case CHIP_R580:
853
	case CHIP_R580:
854
			if (rec->mm_i2c)
854
		if (rec->mm_i2c)
855
				ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
855
			ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
856
			else
856
		else
857
				ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
857
			ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
858
		break;
858
		break;
859
	case CHIP_R600:
859
	case CHIP_R600:
860
	case CHIP_RV610:
860
	case CHIP_RV610:
861
	case CHIP_RV630:
861
	case CHIP_RV630:
862
	case CHIP_RV670:
862
	case CHIP_RV670:
Line 904... Line 904...
904
	.master_xfer = radeon_atom_hw_i2c_xfer,
904
	.master_xfer = radeon_atom_hw_i2c_xfer,
905
	.functionality = radeon_atom_hw_i2c_func,
905
	.functionality = radeon_atom_hw_i2c_func,
906
};
906
};
Line 907... Line 907...
907
 
907
 
908
struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
908
struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
909
		struct radeon_i2c_bus_rec *rec,
909
					  struct radeon_i2c_bus_rec *rec,
910
		const char *name)
910
					  const char *name)
911
{
911
{
912
	struct radeon_device *rdev = dev->dev_private;
912
	struct radeon_device *rdev = dev->dev_private;
913
	struct radeon_i2c_chan *i2c;
913
	struct radeon_i2c_chan *i2c;
Line 922... Line 922...
922
		return NULL;
922
		return NULL;
Line 923... Line 923...
923
 
923
 
924
	i2c->rec = *rec;
924
	i2c->rec = *rec;
925
	i2c->adapter.owner = THIS_MODULE;
925
	i2c->adapter.owner = THIS_MODULE;
-
 
926
	i2c->adapter.class = I2C_CLASS_DDC;
926
	i2c->adapter.class = I2C_CLASS_DDC;
927
	i2c->adapter.dev.parent = &dev->pdev->dev;
927
	i2c->dev = dev;
928
	i2c->dev = dev;
928
	i2c_set_adapdata(&i2c->adapter, i2c);
929
	i2c_set_adapdata(&i2c->adapter, i2c);
929
	mutex_init(&i2c->mutex);
930
	mutex_init(&i2c->mutex);
930
	if (rec->mm_i2c ||
931
	if (rec->mm_i2c ||
Line 966... Line 967...
966
		i2c->bit.getscl = get_clock;
967
		i2c->bit.getscl = get_clock;
967
		i2c->bit.udelay = 10;
968
		i2c->bit.udelay = 10;
968
		i2c->bit.timeout = usecs_to_jiffies(2200);	/* from VESA */
969
		i2c->bit.timeout = usecs_to_jiffies(2200);	/* from VESA */
969
		i2c->bit.data = i2c;
970
		i2c->bit.data = i2c;
970
		ret = i2c_bit_add_bus(&i2c->adapter);
971
		ret = i2c_bit_add_bus(&i2c->adapter);
971
	if (ret) {
972
		if (ret) {
972
			DRM_ERROR("Failed to register bit i2c %s\n", name);
973
			DRM_ERROR("Failed to register bit i2c %s\n", name);
973
		goto out_free;
974
			goto out_free;
974
	}
975
		}
975
	}
976
	}
Line 976... Line 977...
976
 
977
 
977
	return i2c;
978
	return i2c;
978
out_free:
979
out_free:
Line 1045... Line 1046...
1045
		}
1046
		}
1046
	}
1047
	}
1047
	return NULL;
1048
	return NULL;
1048
}
1049
}
Line 1049... Line -...
1049
 
-
 
1050
struct drm_encoder *radeon_best_encoder(struct drm_connector *connector)
-
 
1051
{
-
 
1052
	return NULL;
-
 
1053
}
-
 
1054
 
1050
 
1055
void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus,
1051
void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus,
1056
			    u8 slave_addr,
1052
			 u8 slave_addr,
1057
			    u8 addr,
1053
			 u8 addr,
1058
			    u8 *val)
1054
			 u8 *val)
1059
{
1055
{
1060
	u8 out_buf[2];
1056
	u8 out_buf[2];
1061
	u8 in_buf[2];
1057
	u8 in_buf[2];
1062
	struct i2c_msg msgs[] = {
1058
	struct i2c_msg msgs[] = {
Line 1085... Line 1081...
1085
			  addr, *val);
1081
			  addr, *val);
1086
	}
1082
	}
1087
}
1083
}
Line 1088... Line 1084...
1088
 
1084
 
1089
void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c_bus,
1085
void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c_bus,
1090
			    u8 slave_addr,
1086
			 u8 slave_addr,
1091
			    u8 addr,
1087
			 u8 addr,
1092
			    u8 val)
1088
			 u8 val)
1093
{
1089
{
1094
	uint8_t out_buf[2];
1090
	uint8_t out_buf[2];
1095
	struct i2c_msg msg = {
1091
	struct i2c_msg msg = {
1096
		.addr = slave_addr,
1092
		.addr = slave_addr,
Line 1110... Line 1106...
1110
/* ddc router switching */
1106
/* ddc router switching */
1111
void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector)
1107
void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector)
1112
{
1108
{
1113
	u8 val;
1109
	u8 val;
Line 1114... Line 1110...
1114
 
1110
 
1115
    if (!radeon_connector->router.ddc_valid)
1111
	if (!radeon_connector->router.ddc_valid)
Line 1116... Line 1112...
1116
		return;
1112
		return;
1117
 
1113