59 { 25174, 4576, 28125, 7007, 31250, 6864, 28125 },
60 { 25200, 4096, 25200, 6272, 28000, 6144, 25200 },
61 { 27000, 4096, 27000, 6272, 30000, 6144, 27000 },
62 { 27027, 4096, 27027, 6272, 30030, 6144, 27027 },
63 { 54000, 4096, 54000, 6272, 60000, 6144, 54000 },
64 { 54054, 4096, 54054, 6272, 60060, 6144, 54054 },
65 { 74175, 11648, 210937, 17836, 234375, 11648, 140625 },
66 { 74250, 4096, 74250, 6272, 82500, 6144, 74250 },
67 { 148351, 11648, 421875, 8918, 234375, 5824, 140625 },
68 { 148500, 4096, 148500, 6272, 165000, 6144, 148500 },
69 { 0, 4096, 0, 6272, 0, 6144, 0 }
78 *CTS = clock * N / (128 *
freq) * 1000;
79 DRM_DEBUG(
"Using ACR timing N=%d CTS=%d for frequency %d\n",
88 for (
i = 0; r600_hdmi_predefined_acr[
i].
clock != clock &&
89 r600_hdmi_predefined_acr[
i].
clock != 0;
i++)
91 res = r600_hdmi_predefined_acr[
i];
126 static void r600_hdmi_infoframe_checksum(
uint8_t packetType,
132 frame[0] = packetType + versionNumber +
length;
133 for (i = 1; i <=
length; i++)
134 frame[0] += frame[i];
135 frame[0] = 0x100 - frame[0];
141 static void r600_hdmi_videoinfoframe(
144 int active_information_present,
145 uint8_t active_format_aspect_ratio,
152 uint8_t video_format_identification,
154 uint8_t non_uniform_picture_scaling,
172 (scan_information & 0x3) |
173 ((bar_info_data_valid & 0x3) << 2) |
174 ((active_information_present & 0x1) << 4) |
175 ((color_format & 0x3) << 5);
177 (active_format_aspect_ratio & 0xF) |
178 ((picture_aspect_ratio & 0x3) << 4) |
179 ((colorimetry & 0x3) << 6);
181 (non_uniform_picture_scaling & 0x3) |
182 ((quantization & 0x3) << 2) |
183 ((ex_colorimetry & 0x7) << 4) |
185 frame[0x4] = (video_format_identification & 0x7F);
186 frame[0x5] = (pixel_repetition & 0xF);
187 frame[0x6] = (top_bar & 0xFF);
188 frame[0x7] = (top_bar >> 8);
189 frame[0x8] = (bottom_bar & 0xFF);
190 frame[0x9] = (bottom_bar >> 8);
191 frame[0xA] = (left_bar & 0xFF);
192 frame[0xB] = (left_bar >> 8);
193 frame[0xC] = (right_bar & 0xFF);
194 frame[0xD] = (right_bar >> 8);
196 r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
206 frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
208 frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
210 frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
212 frame[0xC] | (frame[0xD] << 8));
218 static void r600_hdmi_audioinfoframe(
239 frame[0x1] = (channel_count & 0x7) | ((coding_type & 0xF) << 4);
240 frame[0x2] = (sample_size & 0x3) | ((sample_frequency & 0x7) << 2);
242 frame[0x4] = channel_allocation;
243 frame[0x5] = ((level_shift & 0xF) << 3) | ((downmix_inhibit & 0x1) << 7);
250 r600_hdmi_infoframe_checksum(0x84, 0x01, 0x0A, frame);
253 frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
255 frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
261 static bool r600_hdmi_is_audio_buffer_filled(
struct drm_encoder *encoder)
281 if (!dig->
afmt || !dig->
afmt->enabled)
284 status = r600_hdmi_is_audio_buffer_filled(encoder);
285 result = dig->
afmt->last_buffer_filled_status !=
status;
286 dig->
afmt->last_buffer_filled_status =
status;
294 static void r600_hdmi_audio_workaround(
struct drm_encoder *encoder)
301 bool hdmi_audio_workaround =
false;
304 if (!hdmi_audio_workaround ||
305 r600_hdmi_is_audio_buffer_filled(encoder))
326 if (!dig->
afmt->enabled)
328 offset = dig->
afmt->offset;
374 r600_hdmi_videoinfoframe(encoder,
RGB, 0, 0, 0, 0,
375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
377 r600_hdmi_update_ACR(encoder, mode->
clock);
385 r600_hdmi_audio_workaround(encoder);
401 if (!dig->
afmt || !dig->
afmt->enabled)
403 offset = dig->
afmt->offset;
405 DRM_DEBUG(
"%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
406 r600_hdmi_is_audio_buffer_filled(encoder) ?
"playing" :
"stopped",
408 DRM_DEBUG(
"0x%02X IEC60958 status bits and 0x%02X category code\n",
423 switch (audio.
rate) {
465 r600_hdmi_audioinfoframe(encoder, audio.
channels - 1, 0, 0, 0, 0, 0, 0,
468 r600_hdmi_audio_workaround(encoder);
487 if (dig->
afmt->enabled)
489 offset = dig->
afmt->offset;
513 dev_err(rdev->
dev,
"Invalid encoder for HDMI: 0x%X\n",
520 if (rdev->
irq.installed) {
525 dig->
afmt->enabled =
true;
527 DRM_DEBUG(
"Enabling HDMI interface @ 0x%04X for encoder 0x%x\n",
546 if (!dig || !dig->
afmt) {
550 if (!dig->
afmt->enabled)
552 offset = dig->
afmt->offset;
554 DRM_DEBUG(
"Disabling HDMI interface @ 0x%04X for encoder 0x%x\n",
577 dev_err(rdev->
dev,
"Invalid encoder for HDMI: 0x%X\n",
584 dig->
afmt->enabled =
false;