@@ -1184,12 +1184,13 @@ static u32 vc5_hdmi_channel_map(struct vc4_hdmi *vc4_hdmi, u32 channel_mask)
1184
1184
}
1185
1185
1186
1186
/* HDMI audio codec callbacks */
1187
- static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi * vc4_hdmi )
1187
+ static void vc4_hdmi_audio_set_mai_clock (struct vc4_hdmi * vc4_hdmi ,
1188
+ unsigned int samplerate )
1188
1189
{
1189
1190
u32 hsm_clock = clk_get_rate (vc4_hdmi -> audio_clock );
1190
1191
unsigned long n , m ;
1191
1192
1192
- rational_best_approximation (hsm_clock , vc4_hdmi -> audio . samplerate ,
1193
+ rational_best_approximation (hsm_clock , samplerate ,
1193
1194
VC4_HD_MAI_SMP_N_MASK >>
1194
1195
VC4_HD_MAI_SMP_N_SHIFT ,
1195
1196
(VC4_HD_MAI_SMP_M_MASK >>
@@ -1201,12 +1202,11 @@ static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
1201
1202
VC4_SET_FIELD (m - 1 , VC4_HD_MAI_SMP_M ));
1202
1203
}
1203
1204
1204
- static void vc4_hdmi_set_n_cts (struct vc4_hdmi * vc4_hdmi )
1205
+ static void vc4_hdmi_set_n_cts (struct vc4_hdmi * vc4_hdmi , unsigned int samplerate )
1205
1206
{
1206
1207
struct drm_connector * connector = & vc4_hdmi -> connector ;
1207
1208
struct drm_crtc * crtc = connector -> state -> crtc ;
1208
1209
const struct drm_display_mode * mode = & crtc -> state -> adjusted_mode ;
1209
- u32 samplerate = vc4_hdmi -> audio .samplerate ;
1210
1210
u32 n , cts ;
1211
1211
u64 tmp ;
1212
1212
@@ -1340,27 +1340,25 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data,
1340
1340
{
1341
1341
struct vc4_hdmi * vc4_hdmi = dev_get_drvdata (dev );
1342
1342
struct drm_encoder * encoder = & vc4_hdmi -> encoder .base .base ;
1343
+ unsigned int sample_rate = params -> sample_rate ;
1344
+ unsigned int channels = params -> channels ;
1343
1345
u32 audio_packet_config , channel_mask ;
1344
1346
u32 channel_map ;
1345
1347
u32 mai_audio_format ;
1346
1348
u32 mai_sample_rate ;
1347
1349
1348
1350
dev_dbg (dev , "%s: %u Hz, %d bit, %d channels\n" , __func__ ,
1349
- params -> sample_rate , params -> sample_width ,
1350
- params -> channels );
1351
-
1352
- vc4_hdmi -> audio .channels = params -> channels ;
1353
- vc4_hdmi -> audio .samplerate = params -> sample_rate ;
1351
+ sample_rate , params -> sample_width , channels );
1354
1352
1355
1353
HDMI_WRITE (HDMI_MAI_CTL ,
1356
- VC4_SET_FIELD (params -> channels , VC4_HD_MAI_CTL_CHNUM ) |
1354
+ VC4_SET_FIELD (channels , VC4_HD_MAI_CTL_CHNUM ) |
1357
1355
VC4_HD_MAI_CTL_WHOLSMP |
1358
1356
VC4_HD_MAI_CTL_CHALIGN |
1359
1357
VC4_HD_MAI_CTL_ENABLE );
1360
1358
1361
- vc4_hdmi_audio_set_mai_clock (vc4_hdmi );
1359
+ vc4_hdmi_audio_set_mai_clock (vc4_hdmi , sample_rate );
1362
1360
1363
- mai_sample_rate = sample_rate_to_mai_fmt (vc4_hdmi -> audio . samplerate );
1361
+ mai_sample_rate = sample_rate_to_mai_fmt (sample_rate );
1364
1362
if (params -> iec .status [0 ] & IEC958_AES0_NONAUDIO &&
1365
1363
params -> channels == 8 )
1366
1364
mai_audio_format = VC4_HDMI_MAI_FORMAT_HBR ;
@@ -1378,7 +1376,7 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data,
1378
1376
VC4_HDMI_AUDIO_PACKET_ZERO_DATA_ON_INACTIVE_CHANNELS |
1379
1377
VC4_SET_FIELD (0x8 , VC4_HDMI_AUDIO_PACKET_B_FRAME_IDENTIFIER );
1380
1378
1381
- channel_mask = GENMASK (vc4_hdmi -> audio . channels - 1 , 0 );
1379
+ channel_mask = GENMASK (channels - 1 , 0 );
1382
1380
audio_packet_config |= VC4_SET_FIELD (channel_mask ,
1383
1381
VC4_HDMI_AUDIO_PACKET_CEA_MASK );
1384
1382
@@ -1397,7 +1395,7 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data,
1397
1395
channel_map = vc4_hdmi -> variant -> channel_map (vc4_hdmi , channel_mask );
1398
1396
HDMI_WRITE (HDMI_MAI_CHANNEL_MAP , channel_map );
1399
1397
HDMI_WRITE (HDMI_AUDIO_PACKET_CONFIG , audio_packet_config );
1400
- vc4_hdmi_set_n_cts (vc4_hdmi );
1398
+ vc4_hdmi_set_n_cts (vc4_hdmi , sample_rate );
1401
1399
1402
1400
memcpy (& vc4_hdmi -> audio .infoframe , & params -> cea , sizeof (params -> cea ));
1403
1401
vc4_hdmi_set_audio_infoframe (encoder );
0 commit comments