Subversion Repositories Kolibri OS

Rev

Rev 1403 | Rev 2997 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1403 Rev 1963
1
/*
1
/*
2
 * Copyright 2008 Advanced Micro Devices, Inc.
2
 * Copyright 2008 Advanced Micro Devices, Inc.
3
 * Copyright 2008 Red Hat Inc.
3
 * Copyright 2008 Red Hat Inc.
4
 * Copyright 2009 Christian König.
4
 * Copyright 2009 Christian König.
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
12
 *
13
 * The above copyright notice and this permission notice shall be included in
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
14
 * all copies or substantial portions of the Software.
15
 *
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
 * OTHER DEALINGS IN THE SOFTWARE.
22
 * OTHER DEALINGS IN THE SOFTWARE.
23
 *
23
 *
24
 * Authors: Christian König
24
 * Authors: Christian König
25
 */
25
 */
26
#include "drmP.h"
26
#include "drmP.h"
27
#include "radeon_drm.h"
27
#include "radeon_drm.h"
28
#include "radeon.h"
28
#include "radeon.h"
-
 
29
#include "radeon_asic.h"
29
#include "atom.h"
30
#include "atom.h"
30
 
31
 
31
/*
32
/*
32
 * HDMI color format
33
 * HDMI color format
33
 */
34
 */
34
enum r600_hdmi_color_format {
35
enum r600_hdmi_color_format {
35
	RGB = 0,
36
	RGB = 0,
36
	YCC_422 = 1,
37
	YCC_422 = 1,
37
	YCC_444 = 2
38
	YCC_444 = 2
38
};
39
};
39
 
40
 
40
/*
41
/*
41
 * IEC60958 status bits
42
 * IEC60958 status bits
42
 */
43
 */
43
enum r600_hdmi_iec_status_bits {
44
enum r600_hdmi_iec_status_bits {
44
	AUDIO_STATUS_DIG_ENABLE   = 0x01,
45
	AUDIO_STATUS_DIG_ENABLE   = 0x01,
45
	AUDIO_STATUS_V	    = 0x02,
46
	AUDIO_STATUS_V	    = 0x02,
46
	AUDIO_STATUS_VCFG	 = 0x04,
47
	AUDIO_STATUS_VCFG	 = 0x04,
47
	AUDIO_STATUS_EMPHASIS     = 0x08,
48
	AUDIO_STATUS_EMPHASIS     = 0x08,
48
	AUDIO_STATUS_COPYRIGHT    = 0x10,
49
	AUDIO_STATUS_COPYRIGHT    = 0x10,
49
	AUDIO_STATUS_NONAUDIO     = 0x20,
50
	AUDIO_STATUS_NONAUDIO     = 0x20,
50
	AUDIO_STATUS_PROFESSIONAL = 0x40,
51
	AUDIO_STATUS_PROFESSIONAL = 0x40,
51
	AUDIO_STATUS_LEVEL	= 0x80
52
	AUDIO_STATUS_LEVEL	= 0x80
52
};
53
};
53
 
54
 
54
struct {
55
struct {
55
	uint32_t Clock;
56
	uint32_t Clock;
56
 
57
 
57
	int N_32kHz;
58
	int N_32kHz;
58
	int CTS_32kHz;
59
	int CTS_32kHz;
59
 
60
 
60
	int N_44_1kHz;
61
	int N_44_1kHz;
61
	int CTS_44_1kHz;
62
	int CTS_44_1kHz;
62
 
63
 
63
	int N_48kHz;
64
	int N_48kHz;
64
	int CTS_48kHz;
65
	int CTS_48kHz;
65
 
66
 
66
} r600_hdmi_ACR[] = {
67
} r600_hdmi_ACR[] = {
67
    /*	     32kHz	  44.1kHz	48kHz    */
68
    /*	     32kHz	  44.1kHz	48kHz    */
68
    /* Clock      N     CTS      N     CTS      N     CTS */
69
    /* Clock      N     CTS      N     CTS      N     CTS */
69
    {  25174,  4576,  28125,  7007,  31250,  6864,  28125 }, /*  25,20/1.001 MHz */
70
    {  25174,  4576,  28125,  7007,  31250,  6864,  28125 }, /*  25,20/1.001 MHz */
70
    {  25200,  4096,  25200,  6272,  28000,  6144,  25200 }, /*  25.20       MHz */
71
    {  25200,  4096,  25200,  6272,  28000,  6144,  25200 }, /*  25.20       MHz */
71
    {  27000,  4096,  27000,  6272,  30000,  6144,  27000 }, /*  27.00       MHz */
72
    {  27000,  4096,  27000,  6272,  30000,  6144,  27000 }, /*  27.00       MHz */
72
    {  27027,  4096,  27027,  6272,  30030,  6144,  27027 }, /*  27.00*1.001 MHz */
73
    {  27027,  4096,  27027,  6272,  30030,  6144,  27027 }, /*  27.00*1.001 MHz */
73
    {  54000,  4096,  54000,  6272,  60000,  6144,  54000 }, /*  54.00       MHz */
74
    {  54000,  4096,  54000,  6272,  60000,  6144,  54000 }, /*  54.00       MHz */
74
    {  54054,  4096,  54054,  6272,  60060,  6144,  54054 }, /*  54.00*1.001 MHz */
75
    {  54054,  4096,  54054,  6272,  60060,  6144,  54054 }, /*  54.00*1.001 MHz */
75
    {  74175, 11648, 210937, 17836, 234375, 11648, 140625 }, /*  74.25/1.001 MHz */
76
    {  74175, 11648, 210937, 17836, 234375, 11648, 140625 }, /*  74.25/1.001 MHz */
76
    {  74250,  4096,  74250,  6272,  82500,  6144,  74250 }, /*  74.25       MHz */
77
    {  74250,  4096,  74250,  6272,  82500,  6144,  74250 }, /*  74.25       MHz */
77
    { 148351, 11648, 421875,  8918, 234375,  5824, 140625 }, /* 148.50/1.001 MHz */
78
    { 148351, 11648, 421875,  8918, 234375,  5824, 140625 }, /* 148.50/1.001 MHz */
78
    { 148500,  4096, 148500,  6272, 165000,  6144, 148500 }, /* 148.50       MHz */
79
    { 148500,  4096, 148500,  6272, 165000,  6144, 148500 }, /* 148.50       MHz */
79
    {      0,  4096,      0,  6272,      0,  6144,      0 }  /* Other */
80
    {      0,  4096,      0,  6272,      0,  6144,      0 }  /* Other */
80
};
81
};
81
 
82
 
82
/*
83
/*
83
 * calculate CTS value if it's not found in the table
84
 * calculate CTS value if it's not found in the table
84
 */
85
 */
85
static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
86
static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
86
{
87
{
87
	if (*CTS == 0)
88
	if (*CTS == 0)
88
		*CTS = clock*N/(128*freq)*1000;
89
		*CTS = clock * N / (128 * freq) * 1000;
89
	DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
90
	DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
90
		  N, *CTS, freq);
91
		  N, *CTS, freq);
91
}
92
}
92
 
93
 
93
/*
94
/*
94
 * update the N and CTS parameters for a given pixel clock rate
95
 * update the N and CTS parameters for a given pixel clock rate
95
 */
96
 */
96
static void r600_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t clock)
97
static void r600_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t clock)
97
{
98
{
98
	struct drm_device *dev = encoder->dev;
99
	struct drm_device *dev = encoder->dev;
99
	struct radeon_device *rdev = dev->dev_private;
100
	struct radeon_device *rdev = dev->dev_private;
100
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
101
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
101
	int CTS;
102
	int CTS;
102
	int N;
103
	int N;
103
	int i;
104
	int i;
104
 
105
 
105
	for (i = 0; r600_hdmi_ACR[i].Clock != clock && r600_hdmi_ACR[i].Clock != 0; i++);
106
	for (i = 0; r600_hdmi_ACR[i].Clock != clock && r600_hdmi_ACR[i].Clock != 0; i++);
106
 
107
 
107
	CTS = r600_hdmi_ACR[i].CTS_32kHz;
108
	CTS = r600_hdmi_ACR[i].CTS_32kHz;
108
	N = r600_hdmi_ACR[i].N_32kHz;
109
	N = r600_hdmi_ACR[i].N_32kHz;
109
	r600_hdmi_calc_CTS(clock, &CTS, N, 32000);
110
	r600_hdmi_calc_CTS(clock, &CTS, N, 32000);
110
	WREG32(offset+R600_HDMI_32kHz_CTS, CTS << 12);
111
	WREG32(offset+R600_HDMI_32kHz_CTS, CTS << 12);
111
	WREG32(offset+R600_HDMI_32kHz_N, N);
112
	WREG32(offset+R600_HDMI_32kHz_N, N);
112
 
113
 
113
	CTS = r600_hdmi_ACR[i].CTS_44_1kHz;
114
	CTS = r600_hdmi_ACR[i].CTS_44_1kHz;
114
	N = r600_hdmi_ACR[i].N_44_1kHz;
115
	N = r600_hdmi_ACR[i].N_44_1kHz;
115
	r600_hdmi_calc_CTS(clock, &CTS, N, 44100);
116
	r600_hdmi_calc_CTS(clock, &CTS, N, 44100);
116
	WREG32(offset+R600_HDMI_44_1kHz_CTS, CTS << 12);
117
	WREG32(offset+R600_HDMI_44_1kHz_CTS, CTS << 12);
117
	WREG32(offset+R600_HDMI_44_1kHz_N, N);
118
	WREG32(offset+R600_HDMI_44_1kHz_N, N);
118
 
119
 
119
	CTS = r600_hdmi_ACR[i].CTS_48kHz;
120
	CTS = r600_hdmi_ACR[i].CTS_48kHz;
120
	N = r600_hdmi_ACR[i].N_48kHz;
121
	N = r600_hdmi_ACR[i].N_48kHz;
121
	r600_hdmi_calc_CTS(clock, &CTS, N, 48000);
122
	r600_hdmi_calc_CTS(clock, &CTS, N, 48000);
122
	WREG32(offset+R600_HDMI_48kHz_CTS, CTS << 12);
123
	WREG32(offset+R600_HDMI_48kHz_CTS, CTS << 12);
123
	WREG32(offset+R600_HDMI_48kHz_N, N);
124
	WREG32(offset+R600_HDMI_48kHz_N, N);
124
}
125
}
125
 
126
 
126
/*
127
/*
127
 * calculate the crc for a given info frame
128
 * calculate the crc for a given info frame
128
 */
129
 */
129
static void r600_hdmi_infoframe_checksum(uint8_t packetType,
130
static void r600_hdmi_infoframe_checksum(uint8_t packetType,
130
					 uint8_t versionNumber,
131
					 uint8_t versionNumber,
131
					 uint8_t length,
132
					 uint8_t length,
132
					 uint8_t *frame)
133
					 uint8_t *frame)
133
{
134
{
134
    int i;
135
    int i;
135
    frame[0] = packetType + versionNumber + length;
136
    frame[0] = packetType + versionNumber + length;
136
    for (i = 1; i <= length; i++)
137
    for (i = 1; i <= length; i++)
137
	frame[0] += frame[i];
138
	frame[0] += frame[i];
138
    frame[0] = 0x100 - frame[0];
139
    frame[0] = 0x100 - frame[0];
139
}
140
}
140
 
141
 
141
/*
142
/*
142
 * build a HDMI Video Info Frame
143
 * build a HDMI Video Info Frame
143
 */
144
 */
144
static void r600_hdmi_videoinfoframe(
145
static void r600_hdmi_videoinfoframe(
145
	struct drm_encoder *encoder,
146
	struct drm_encoder *encoder,
146
	enum r600_hdmi_color_format color_format,
147
	enum r600_hdmi_color_format color_format,
147
	int active_information_present,
148
	int active_information_present,
148
	uint8_t active_format_aspect_ratio,
149
	uint8_t active_format_aspect_ratio,
149
	uint8_t scan_information,
150
	uint8_t scan_information,
150
	uint8_t colorimetry,
151
	uint8_t colorimetry,
151
	uint8_t ex_colorimetry,
152
	uint8_t ex_colorimetry,
152
	uint8_t quantization,
153
	uint8_t quantization,
153
	int ITC,
154
	int ITC,
154
	uint8_t picture_aspect_ratio,
155
	uint8_t picture_aspect_ratio,
155
	uint8_t video_format_identification,
156
	uint8_t video_format_identification,
156
	uint8_t pixel_repetition,
157
	uint8_t pixel_repetition,
157
	uint8_t non_uniform_picture_scaling,
158
	uint8_t non_uniform_picture_scaling,
158
	uint8_t bar_info_data_valid,
159
	uint8_t bar_info_data_valid,
159
	uint16_t top_bar,
160
	uint16_t top_bar,
160
	uint16_t bottom_bar,
161
	uint16_t bottom_bar,
161
	uint16_t left_bar,
162
	uint16_t left_bar,
162
	uint16_t right_bar
163
	uint16_t right_bar
163
)
164
)
164
{
165
{
165
	struct drm_device *dev = encoder->dev;
166
	struct drm_device *dev = encoder->dev;
166
	struct radeon_device *rdev = dev->dev_private;
167
	struct radeon_device *rdev = dev->dev_private;
167
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
168
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
168
 
169
 
169
	uint8_t frame[14];
170
	uint8_t frame[14];
170
 
171
 
171
	frame[0x0] = 0;
172
	frame[0x0] = 0;
172
	frame[0x1] =
173
	frame[0x1] =
173
		(scan_information & 0x3) |
174
		(scan_information & 0x3) |
174
		((bar_info_data_valid & 0x3) << 2) |
175
		((bar_info_data_valid & 0x3) << 2) |
175
		((active_information_present & 0x1) << 4) |
176
		((active_information_present & 0x1) << 4) |
176
		((color_format & 0x3) << 5);
177
		((color_format & 0x3) << 5);
177
	frame[0x2] =
178
	frame[0x2] =
178
		(active_format_aspect_ratio & 0xF) |
179
		(active_format_aspect_ratio & 0xF) |
179
		((picture_aspect_ratio & 0x3) << 4) |
180
		((picture_aspect_ratio & 0x3) << 4) |
180
		((colorimetry & 0x3) << 6);
181
		((colorimetry & 0x3) << 6);
181
	frame[0x3] =
182
	frame[0x3] =
182
		(non_uniform_picture_scaling & 0x3) |
183
		(non_uniform_picture_scaling & 0x3) |
183
		((quantization & 0x3) << 2) |
184
		((quantization & 0x3) << 2) |
184
		((ex_colorimetry & 0x7) << 4) |
185
		((ex_colorimetry & 0x7) << 4) |
185
		((ITC & 0x1) << 7);
186
		((ITC & 0x1) << 7);
186
	frame[0x4] = (video_format_identification & 0x7F);
187
	frame[0x4] = (video_format_identification & 0x7F);
187
	frame[0x5] = (pixel_repetition & 0xF);
188
	frame[0x5] = (pixel_repetition & 0xF);
188
	frame[0x6] = (top_bar & 0xFF);
189
	frame[0x6] = (top_bar & 0xFF);
189
	frame[0x7] = (top_bar >> 8);
190
	frame[0x7] = (top_bar >> 8);
190
	frame[0x8] = (bottom_bar & 0xFF);
191
	frame[0x8] = (bottom_bar & 0xFF);
191
	frame[0x9] = (bottom_bar >> 8);
192
	frame[0x9] = (bottom_bar >> 8);
192
	frame[0xA] = (left_bar & 0xFF);
193
	frame[0xA] = (left_bar & 0xFF);
193
	frame[0xB] = (left_bar >> 8);
194
	frame[0xB] = (left_bar >> 8);
194
	frame[0xC] = (right_bar & 0xFF);
195
	frame[0xC] = (right_bar & 0xFF);
195
	frame[0xD] = (right_bar >> 8);
196
	frame[0xD] = (right_bar >> 8);
196
 
197
 
197
	r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
198
	r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
198
 
199
 
199
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_0,
200
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_0,
200
		frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
201
		frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
201
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_1,
202
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_1,
202
		frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
203
		frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
203
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_2,
204
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_2,
204
		frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
205
		frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
205
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_3,
206
	WREG32(offset+R600_HDMI_VIDEOINFOFRAME_3,
206
		frame[0xC] | (frame[0xD] << 8));
207
		frame[0xC] | (frame[0xD] << 8));
207
}
208
}
208
 
209
 
209
/*
210
/*
210
 * build a Audio Info Frame
211
 * build a Audio Info Frame
211
 */
212
 */
212
static void r600_hdmi_audioinfoframe(
213
static void r600_hdmi_audioinfoframe(
213
	struct drm_encoder *encoder,
214
	struct drm_encoder *encoder,
214
	uint8_t channel_count,
215
	uint8_t channel_count,
215
	uint8_t coding_type,
216
	uint8_t coding_type,
216
	uint8_t sample_size,
217
	uint8_t sample_size,
217
	uint8_t sample_frequency,
218
	uint8_t sample_frequency,
218
	uint8_t format,
219
	uint8_t format,
219
	uint8_t channel_allocation,
220
	uint8_t channel_allocation,
220
	uint8_t level_shift,
221
	uint8_t level_shift,
221
	int downmix_inhibit
222
	int downmix_inhibit
222
)
223
)
223
{
224
{
224
	struct drm_device *dev = encoder->dev;
225
	struct drm_device *dev = encoder->dev;
225
	struct radeon_device *rdev = dev->dev_private;
226
	struct radeon_device *rdev = dev->dev_private;
226
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
227
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
227
 
228
 
228
	uint8_t frame[11];
229
	uint8_t frame[11];
229
 
230
 
230
	frame[0x0] = 0;
231
	frame[0x0] = 0;
231
	frame[0x1] = (channel_count & 0x7) | ((coding_type & 0xF) << 4);
232
	frame[0x1] = (channel_count & 0x7) | ((coding_type & 0xF) << 4);
232
	frame[0x2] = (sample_size & 0x3) | ((sample_frequency & 0x7) << 2);
233
	frame[0x2] = (sample_size & 0x3) | ((sample_frequency & 0x7) << 2);
233
	frame[0x3] = format;
234
	frame[0x3] = format;
234
	frame[0x4] = channel_allocation;
235
	frame[0x4] = channel_allocation;
235
	frame[0x5] = ((level_shift & 0xF) << 3) | ((downmix_inhibit & 0x1) << 7);
236
	frame[0x5] = ((level_shift & 0xF) << 3) | ((downmix_inhibit & 0x1) << 7);
236
	frame[0x6] = 0;
237
	frame[0x6] = 0;
237
	frame[0x7] = 0;
238
	frame[0x7] = 0;
238
	frame[0x8] = 0;
239
	frame[0x8] = 0;
239
	frame[0x9] = 0;
240
	frame[0x9] = 0;
240
	frame[0xA] = 0;
241
	frame[0xA] = 0;
241
 
242
 
242
	r600_hdmi_infoframe_checksum(0x84, 0x01, 0x0A, frame);
243
	r600_hdmi_infoframe_checksum(0x84, 0x01, 0x0A, frame);
243
 
244
 
244
	WREG32(offset+R600_HDMI_AUDIOINFOFRAME_0,
245
	WREG32(offset+R600_HDMI_AUDIOINFOFRAME_0,
245
		frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
246
		frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
246
	WREG32(offset+R600_HDMI_AUDIOINFOFRAME_1,
247
	WREG32(offset+R600_HDMI_AUDIOINFOFRAME_1,
247
		frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
248
		frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
248
}
249
}
249
 
250
 
250
/*
251
/*
251
 * test if audio buffer is filled enough to start playing
252
 * test if audio buffer is filled enough to start playing
252
 */
253
 */
253
static int r600_hdmi_is_audio_buffer_filled(struct drm_encoder *encoder)
254
static int r600_hdmi_is_audio_buffer_filled(struct drm_encoder *encoder)
254
{
255
{
255
	struct drm_device *dev = encoder->dev;
256
	struct drm_device *dev = encoder->dev;
256
	struct radeon_device *rdev = dev->dev_private;
257
	struct radeon_device *rdev = dev->dev_private;
257
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
258
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
258
 
259
 
259
	return (RREG32(offset+R600_HDMI_STATUS) & 0x10) != 0;
260
	return (RREG32(offset+R600_HDMI_STATUS) & 0x10) != 0;
260
}
261
}
261
 
262
 
262
/*
263
/*
263
 * have buffer status changed since last call?
264
 * have buffer status changed since last call?
264
 */
265
 */
265
int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder)
266
int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder)
266
{
267
{
267
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
268
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
268
	int status, result;
269
	int status, result;
269
 
270
 
270
	if (!radeon_encoder->hdmi_offset)
271
	if (!radeon_encoder->hdmi_offset)
271
		return 0;
272
		return 0;
272
 
273
 
273
	status = r600_hdmi_is_audio_buffer_filled(encoder);
274
	status = r600_hdmi_is_audio_buffer_filled(encoder);
274
	result = radeon_encoder->hdmi_buffer_status != status;
275
	result = radeon_encoder->hdmi_buffer_status != status;
275
	radeon_encoder->hdmi_buffer_status = status;
276
	radeon_encoder->hdmi_buffer_status = status;
276
 
277
 
277
	return result;
278
	return result;
278
}
279
}
279
 
280
 
280
/*
281
/*
281
 * write the audio workaround status to the hardware
282
 * write the audio workaround status to the hardware
282
 */
283
 */
283
void r600_hdmi_audio_workaround(struct drm_encoder *encoder)
284
void r600_hdmi_audio_workaround(struct drm_encoder *encoder)
284
{
285
{
285
	struct drm_device *dev = encoder->dev;
286
	struct drm_device *dev = encoder->dev;
286
	struct radeon_device *rdev = dev->dev_private;
287
	struct radeon_device *rdev = dev->dev_private;
287
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
288
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
288
	uint32_t offset = radeon_encoder->hdmi_offset;
289
	uint32_t offset = radeon_encoder->hdmi_offset;
289
 
290
 
290
	if (!offset)
291
	if (!offset)
291
		return;
292
		return;
-
 
293
 
292
 
294
	if (!radeon_encoder->hdmi_audio_workaround ||
293
	if (r600_hdmi_is_audio_buffer_filled(encoder)) {
-
 
294
		/* disable audio workaround and start delivering of audio frames */
-
 
295
		WREG32_P(offset+R600_HDMI_CNTL, 0x00000001, ~0x00001001);
295
		r600_hdmi_is_audio_buffer_filled(encoder)) {
296
 
-
 
297
	} else if (radeon_encoder->hdmi_audio_workaround) {
296
 
298
		/* enable audio workaround and start delivering of audio frames */
297
		/* disable audio workaround */
299
		WREG32_P(offset+R600_HDMI_CNTL, 0x00001001, ~0x00001001);
298
		WREG32_P(offset+R600_HDMI_CNTL, 0x00000001, ~0x00001001);
300
 
299
 
301
	} else {
300
	} else {
302
		/* disable audio workaround and stop delivering of audio frames */
301
		/* enable audio workaround */
303
		WREG32_P(offset+R600_HDMI_CNTL, 0x00000000, ~0x00001001);
302
		WREG32_P(offset+R600_HDMI_CNTL, 0x00001001, ~0x00001001);
304
	}
303
	}
305
}
304
}
306
 
305
 
307
 
306
 
308
/*
307
/*
309
 * update the info frames with the data from the current display mode
308
 * update the info frames with the data from the current display mode
310
 */
309
 */
311
void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode)
310
void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode)
312
{
311
{
313
	struct drm_device *dev = encoder->dev;
312
	struct drm_device *dev = encoder->dev;
314
	struct radeon_device *rdev = dev->dev_private;
313
	struct radeon_device *rdev = dev->dev_private;
315
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
314
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
-
 
315
 
-
 
316
	if (ASIC_IS_DCE4(rdev))
-
 
317
		return;
316
 
318
 
317
	if (!offset)
319
	if (!offset)
318
		return;
320
		return;
319
 
321
 
320
	r600_audio_set_clock(encoder, mode->clock);
322
	r600_audio_set_clock(encoder, mode->clock);
321
 
323
 
322
	WREG32(offset+R600_HDMI_UNKNOWN_0, 0x1000);
324
	WREG32(offset+R600_HDMI_UNKNOWN_0, 0x1000);
323
	WREG32(offset+R600_HDMI_UNKNOWN_1, 0x0);
325
	WREG32(offset+R600_HDMI_UNKNOWN_1, 0x0);
324
	WREG32(offset+R600_HDMI_UNKNOWN_2, 0x1000);
326
	WREG32(offset+R600_HDMI_UNKNOWN_2, 0x1000);
325
 
327
 
326
	r600_hdmi_update_ACR(encoder, mode->clock);
328
	r600_hdmi_update_ACR(encoder, mode->clock);
327
 
329
 
328
	WREG32(offset+R600_HDMI_VIDEOCNTL, 0x13);
330
	WREG32(offset+R600_HDMI_VIDEOCNTL, 0x13);
329
 
331
 
330
	WREG32(offset+R600_HDMI_VERSION, 0x202);
332
	WREG32(offset+R600_HDMI_VERSION, 0x202);
331
 
333
 
332
	r600_hdmi_videoinfoframe(encoder, RGB, 0, 0, 0, 0,
334
	r600_hdmi_videoinfoframe(encoder, RGB, 0, 0, 0, 0,
333
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
335
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
334
 
336
 
335
	/* it's unknown what these bits do excatly, but it's indeed quite usefull for debugging */
337
	/* it's unknown what these bits do excatly, but it's indeed quite useful for debugging */
336
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_0, 0x00FFFFFF);
338
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_0, 0x00FFFFFF);
337
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_1, 0x007FFFFF);
339
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_1, 0x007FFFFF);
338
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_2, 0x00000001);
340
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_2, 0x00000001);
339
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_3, 0x00000001);
341
	WREG32(offset+R600_HDMI_AUDIO_DEBUG_3, 0x00000001);
340
 
342
 
341
	r600_hdmi_audio_workaround(encoder);
343
	r600_hdmi_audio_workaround(encoder);
342
 
344
 
343
	/* audio packets per line, does anyone know how to calc this ? */
345
	/* audio packets per line, does anyone know how to calc this ? */
344
	WREG32_P(offset+R600_HDMI_CNTL, 0x00040000, ~0x001F0000);
346
	WREG32_P(offset+R600_HDMI_CNTL, 0x00040000, ~0x001F0000);
345
 
-
 
346
	/* update? reset? don't realy know */
-
 
347
	WREG32_P(offset+R600_HDMI_CNTL, 0x14000000, ~0x14000000);
-
 
348
}
347
}
349
 
348
 
350
/*
349
/*
351
 * update settings with current parameters from audio engine
350
 * update settings with current parameters from audio engine
352
 */
351
 */
353
void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
352
void r600_hdmi_update_audio_settings(struct drm_encoder *encoder)
354
				     int channels,
-
 
355
				     int rate,
-
 
356
				     int bps,
-
 
357
				     uint8_t status_bits,
-
 
358
				     uint8_t category_code)
-
 
359
{
353
{
360
	struct drm_device *dev = encoder->dev;
354
	struct drm_device *dev = encoder->dev;
361
	struct radeon_device *rdev = dev->dev_private;
355
	struct radeon_device *rdev = dev->dev_private;
362
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
356
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
-
 
357
 
-
 
358
	int channels = r600_audio_channels(rdev);
-
 
359
	int rate = r600_audio_rate(rdev);
-
 
360
	int bps = r600_audio_bits_per_sample(rdev);
-
 
361
	uint8_t status_bits = r600_audio_status_bits(rdev);
-
 
362
	uint8_t category_code = r600_audio_category_code(rdev);
363
 
363
 
364
	uint32_t iec;
364
	uint32_t iec;
365
 
365
 
366
	if (!offset)
366
	if (!offset)
367
		return;
367
		return;
368
 
368
 
369
	DRM_DEBUG("%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
369
	DRM_DEBUG("%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
370
		 r600_hdmi_is_audio_buffer_filled(encoder) ? "playing" : "stopped",
370
		 r600_hdmi_is_audio_buffer_filled(encoder) ? "playing" : "stopped",
371
		channels, rate, bps);
371
		channels, rate, bps);
372
	DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n",
372
	DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n",
373
		  (int)status_bits, (int)category_code);
373
		  (int)status_bits, (int)category_code);
374
 
374
 
375
	iec = 0;
375
	iec = 0;
376
	if (status_bits & AUDIO_STATUS_PROFESSIONAL)
376
	if (status_bits & AUDIO_STATUS_PROFESSIONAL)
377
		iec |= 1 << 0;
377
		iec |= 1 << 0;
378
	if (status_bits & AUDIO_STATUS_NONAUDIO)
378
	if (status_bits & AUDIO_STATUS_NONAUDIO)
379
		iec |= 1 << 1;
379
		iec |= 1 << 1;
380
	if (status_bits & AUDIO_STATUS_COPYRIGHT)
380
	if (status_bits & AUDIO_STATUS_COPYRIGHT)
381
		iec |= 1 << 2;
381
		iec |= 1 << 2;
382
	if (status_bits & AUDIO_STATUS_EMPHASIS)
382
	if (status_bits & AUDIO_STATUS_EMPHASIS)
383
		iec |= 1 << 3;
383
		iec |= 1 << 3;
384
 
384
 
385
	iec |= category_code << 8;
385
	iec |= category_code << 8;
386
 
386
 
387
	switch (rate) {
387
	switch (rate) {
388
	case  32000: iec |= 0x3 << 24; break;
388
	case  32000: iec |= 0x3 << 24; break;
389
	case  44100: iec |= 0x0 << 24; break;
389
	case  44100: iec |= 0x0 << 24; break;
390
	case  88200: iec |= 0x8 << 24; break;
390
	case  88200: iec |= 0x8 << 24; break;
391
	case 176400: iec |= 0xc << 24; break;
391
	case 176400: iec |= 0xc << 24; break;
392
	case  48000: iec |= 0x2 << 24; break;
392
	case  48000: iec |= 0x2 << 24; break;
393
	case  96000: iec |= 0xa << 24; break;
393
	case  96000: iec |= 0xa << 24; break;
394
	case 192000: iec |= 0xe << 24; break;
394
	case 192000: iec |= 0xe << 24; break;
395
	}
395
	}
396
 
396
 
397
	WREG32(offset+R600_HDMI_IEC60958_1, iec);
397
	WREG32(offset+R600_HDMI_IEC60958_1, iec);
398
 
398
 
399
	iec = 0;
399
	iec = 0;
400
	switch (bps) {
400
	switch (bps) {
401
	case 16: iec |= 0x2; break;
401
	case 16: iec |= 0x2; break;
402
	case 20: iec |= 0x3; break;
402
	case 20: iec |= 0x3; break;
403
	case 24: iec |= 0xb; break;
403
	case 24: iec |= 0xb; break;
404
	}
404
	}
405
	if (status_bits & AUDIO_STATUS_V)
405
	if (status_bits & AUDIO_STATUS_V)
406
		iec |= 0x5 << 16;
406
		iec |= 0x5 << 16;
407
 
407
 
408
	WREG32_P(offset+R600_HDMI_IEC60958_2, iec, ~0x5000f);
408
	WREG32_P(offset+R600_HDMI_IEC60958_2, iec, ~0x5000f);
409
 
409
 
410
	/* 0x021 or 0x031 sets the audio frame length */
410
	/* 0x021 or 0x031 sets the audio frame length */
411
	WREG32(offset+R600_HDMI_AUDIOCNTL, 0x31);
411
	WREG32(offset+R600_HDMI_AUDIOCNTL, 0x31);
412
	r600_hdmi_audioinfoframe(encoder, channels-1, 0, 0, 0, 0, 0, 0, 0);
412
	r600_hdmi_audioinfoframe(encoder, channels-1, 0, 0, 0, 0, 0, 0, 0);
413
 
413
 
414
	r600_hdmi_audio_workaround(encoder);
414
	r600_hdmi_audio_workaround(encoder);
-
 
415
}
-
 
416
 
-
 
417
static int r600_hdmi_find_free_block(struct drm_device *dev)
-
 
418
{
-
 
419
	struct radeon_device *rdev = dev->dev_private;
-
 
420
	struct drm_encoder *encoder;
-
 
421
	struct radeon_encoder *radeon_encoder;
-
 
422
	bool free_blocks[3] = { true, true, true };
-
 
423
 
-
 
424
	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-
 
425
		radeon_encoder = to_radeon_encoder(encoder);
-
 
426
		switch (radeon_encoder->hdmi_offset) {
-
 
427
		case R600_HDMI_BLOCK1:
-
 
428
			free_blocks[0] = false;
-
 
429
			break;
-
 
430
		case R600_HDMI_BLOCK2:
-
 
431
			free_blocks[1] = false;
-
 
432
			break;
-
 
433
		case R600_HDMI_BLOCK3:
-
 
434
			free_blocks[2] = false;
-
 
435
			break;
-
 
436
		}
-
 
437
	}
-
 
438
 
-
 
439
	if (rdev->family == CHIP_RS600 || rdev->family == CHIP_RS690 ||
-
 
440
	    rdev->family == CHIP_RS740) {
-
 
441
		return free_blocks[0] ? R600_HDMI_BLOCK1 : 0;
-
 
442
	} else if (rdev->family >= CHIP_R600) {
-
 
443
		if (free_blocks[0])
-
 
444
			return R600_HDMI_BLOCK1;
-
 
445
		else if (free_blocks[1])
-
 
446
			return R600_HDMI_BLOCK2;
-
 
447
	}
-
 
448
	return 0;
-
 
449
}
-
 
450
 
-
 
451
static void r600_hdmi_assign_block(struct drm_encoder *encoder)
415
 
452
{
-
 
453
	struct drm_device *dev = encoder->dev;
-
 
454
	struct radeon_device *rdev = dev->dev_private;
-
 
455
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-
 
456
	struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
-
 
457
 
-
 
458
	if (!dig) {
-
 
459
		dev_err(rdev->dev, "Enabling HDMI on non-dig encoder\n");
-
 
460
		return;
-
 
461
	}
-
 
462
 
-
 
463
	if (ASIC_IS_DCE4(rdev)) {
-
 
464
		/* TODO */
-
 
465
	} else if (ASIC_IS_DCE3(rdev)) {
-
 
466
		radeon_encoder->hdmi_offset = dig->dig_encoder ?
-
 
467
			R600_HDMI_BLOCK3 : R600_HDMI_BLOCK1;
-
 
468
		if (ASIC_IS_DCE32(rdev))
416
	/* update? reset? don't realy know */
469
			radeon_encoder->hdmi_config_offset = dig->dig_encoder ?
-
 
470
				R600_HDMI_CONFIG2 : R600_HDMI_CONFIG1;
-
 
471
	} else if (rdev->family >= CHIP_R600 || rdev->family == CHIP_RS600 ||
-
 
472
		   rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
-
 
473
		radeon_encoder->hdmi_offset = r600_hdmi_find_free_block(dev);
417
	WREG32_P(offset+R600_HDMI_CNTL, 0x04000000, ~0x04000000);
474
	}
418
}
475
}
419
 
476
 
420
/*
477
/*
421
 * enable/disable the HDMI engine
478
 * enable the HDMI engine
422
 */
479
 */
423
void r600_hdmi_enable(struct drm_encoder *encoder, int enable)
480
void r600_hdmi_enable(struct drm_encoder *encoder)
424
{
481
{
425
	struct drm_device *dev = encoder->dev;
482
	struct drm_device *dev = encoder->dev;
426
	struct radeon_device *rdev = dev->dev_private;
483
	struct radeon_device *rdev = dev->dev_private;
427
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
484
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
428
	uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
485
	uint32_t offset;
429
 
486
 
430
	if (!offset)
487
	if (ASIC_IS_DCE4(rdev))
-
 
488
		return;
-
 
489
 
-
 
490
	if (!radeon_encoder->hdmi_offset) {
431
		return;
491
		r600_hdmi_assign_block(encoder);
-
 
492
		if (!radeon_encoder->hdmi_offset) {
-
 
493
			dev_warn(rdev->dev, "Could not find HDMI block for "
-
 
494
				"0x%x encoder\n", radeon_encoder->encoder_id);
-
 
495
		return;
-
 
496
		}
-
 
497
	}
432
 
498
 
433
	DRM_DEBUG("%s HDMI interface @ 0x%04X\n", enable ? "Enabling" : "Disabling", offset);
499
	offset = radeon_encoder->hdmi_offset;
434
 
500
	if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
435
	/* some version of atombios ignore the enable HDMI flag
501
		WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0x1, ~0x1);
436
	 * so enabling/disabling HDMI was moved here for TMDS1+2 */
502
	} else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
437
	switch (radeon_encoder->encoder_id) {
503
	switch (radeon_encoder->encoder_id) {
438
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
504
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
439
		WREG32_P(AVIVO_TMDSA_CNTL, enable ? 0x4 : 0x0, ~0x4);
-
 
440
		WREG32(offset+R600_HDMI_ENABLE, enable ? 0x101 : 0x0);
505
			WREG32_P(AVIVO_TMDSA_CNTL, 0x4, ~0x4);
441
		break;
506
			WREG32(offset + R600_HDMI_ENABLE, 0x101);
442
 
507
		break;
443
	case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
-
 
444
		WREG32_P(AVIVO_LVTMA_CNTL, enable ? 0x4 : 0x0, ~0x4);
-
 
445
		WREG32(offset+R600_HDMI_ENABLE, enable ? 0x105 : 0x0);
-
 
446
		break;
-
 
447
 
-
 
448
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
-
 
449
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
-
 
450
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
-
 
451
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
508
	case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
452
		/* This part is doubtfull in my opinion */
-
 
453
		WREG32(offset+R600_HDMI_ENABLE, enable ? 0x110 : 0x0);
509
			WREG32_P(AVIVO_LVTMA_CNTL, 0x4, ~0x4);
454
		break;
510
			WREG32(offset + R600_HDMI_ENABLE, 0x105);
455
 
511
		break;
456
	default:
512
	default:
457
		DRM_ERROR("unknown HDMI output type\n");
513
			dev_err(rdev->dev, "Unknown HDMI output type\n");
458
		break;
514
		break;
459
	}
515
	}
460
}
516
	}
-
 
517
#if 0
-
 
518
	if (rdev->irq.installed
-
 
519
	    && rdev->family != CHIP_RS600
-
 
520
	    && rdev->family != CHIP_RS690
-
 
521
	    && rdev->family != CHIP_RS740) {
-
 
522
 
-
 
523
		/* if irq is available use it */
-
 
524
		rdev->irq.hdmi[offset == R600_HDMI_BLOCK1 ? 0 : 1] = true;
-
 
525
		radeon_irq_set(rdev);
-
 
526
 
-
 
527
		r600_audio_disable_polling(encoder);
-
 
528
	} else {
-
 
529
		/* if not fallback to polling */
-
 
530
		r600_audio_enable_polling(encoder);
-
 
531
	}
-
 
532
#endif
-
 
533
	DRM_DEBUG("Enabling HDMI interface @ 0x%04X for encoder 0x%x\n",
-
 
534
		radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
-
 
535
}
461
 
536
 
462
/*
537
/*
463
 * determin at which register offset the HDMI encoder is
538
 * disable the HDMI engine
464
 */
539
 */
465
void r600_hdmi_init(struct drm_encoder *encoder)
540
void r600_hdmi_disable(struct drm_encoder *encoder)
-
 
541
{
-
 
542
	struct drm_device *dev = encoder->dev;
466
{
543
	struct radeon_device *rdev = dev->dev_private;
-
 
544
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-
 
545
	uint32_t offset;
-
 
546
 
-
 
547
	if (ASIC_IS_DCE4(rdev))
-
 
548
		return;
-
 
549
 
-
 
550
	offset = radeon_encoder->hdmi_offset;
-
 
551
	if (!offset) {
-
 
552
		dev_err(rdev->dev, "Disabling not enabled HDMI\n");
-
 
553
		return;
-
 
554
	}
-
 
555
 
-
 
556
	DRM_DEBUG("Disabling HDMI interface @ 0x%04X for encoder 0x%x\n",
-
 
557
		offset, radeon_encoder->encoder_id);
-
 
558
 
-
 
559
	if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
467
	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
560
		WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0, ~0x1);
468
 
561
	} else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
469
	switch (radeon_encoder->encoder_id) {
562
	switch (radeon_encoder->encoder_id) {
470
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
-
 
471
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
563
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
472
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
564
			WREG32_P(AVIVO_TMDSA_CNTL, 0, ~0x4);
473
		radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
-
 
474
		break;
565
			WREG32(offset + R600_HDMI_ENABLE, 0);
475
 
-
 
476
	case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
-
 
477
		switch (r600_audio_tmds_index(encoder)) {
566
		break;
478
		case 0:
-
 
479
			radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
-
 
480
			break;
567
	case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
481
		case 1:
568
			WREG32_P(AVIVO_LVTMA_CNTL, 0, ~0x4);
482
			radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
569
			WREG32(offset + R600_HDMI_ENABLE, 0);
483
			break;
570
			break;
484
		default:
571
		default:
485
			radeon_encoder->hdmi_offset = 0;
572
			dev_err(rdev->dev, "Unknown HDMI output type\n");
486
			break;
-
 
487
		}
-
 
488
	case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
-
 
489
		radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
-
 
490
		break;
-
 
491
 
-
 
492
	case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
-
 
493
		radeon_encoder->hdmi_offset = R600_HDMI_DIG;
-
 
494
		break;
-
 
495
 
-
 
496
	default:
-
 
497
		radeon_encoder->hdmi_offset = 0;
573
			break;
498
		break;
-
 
499
	}
574
		}
500
 
-
 
501
	DRM_DEBUG("using HDMI engine at offset 0x%04X for encoder 0x%x\n",
-
 
502
		  radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
575
	}
503
 
576
 
504
	/* TODO: make this configureable */
577
		radeon_encoder->hdmi_offset = 0;
505
	radeon_encoder->hdmi_audio_workaround = 0;
578
	radeon_encoder->hdmi_config_offset = 0;
506
}
579
}