Skip to content

Commit c979296

Browse files
committed
drm: xlnx: zynqmp_dpsub: Move audio clk from zynqmp_disp to zynqmp_dpsub
The audio clock is an external resource from the DPSUB point of view, not a resource internal to the display controller. Move it to the zynqmp_dpsub structure, to allow accessing it from outside the disp code. Signed-off-by: Laurent Pinchart <[email protected]>
1 parent 1682ade commit c979296

File tree

5 files changed

+65
-60
lines changed

5 files changed

+65
-60
lines changed

drivers/gpu/drm/xlnx/zynqmp_disp.c

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ struct zynqmp_disp_layer {
166166
* @blend.base: Register I/O base address for the blender
167167
* @avbuf.base: Register I/O base address for the audio/video buffer manager
168168
* @audio.base: Registers I/O base address for the audio mixer
169-
* @audio.clk: Audio clock
170-
* @audio.clk_from_ps: True of the audio clock comes from PS, false from PL
171169
* @layers: Layers (planes)
172170
*/
173171
struct zynqmp_disp {
@@ -185,8 +183,6 @@ struct zynqmp_disp {
185183
} avbuf;
186184
struct {
187185
void __iomem *base;
188-
struct clk *clk;
189-
bool clk_from_ps;
190186
} audio;
191187

192188
struct zynqmp_disp_layer layers[ZYNQMP_DISP_NUM_LAYERS];
@@ -892,25 +888,6 @@ static void zynqmp_disp_audio_disable(struct zynqmp_disp *disp)
892888
ZYNQMP_DISP_AUD_SOFT_RESET_AUD_SRST);
893889
}
894890

895-
static void zynqmp_disp_audio_init(struct zynqmp_disp *disp)
896-
{
897-
/* Try the live PL audio clock. */
898-
disp->audio.clk = devm_clk_get(disp->dev, "dp_live_audio_aclk");
899-
if (!IS_ERR(disp->audio.clk)) {
900-
disp->audio.clk_from_ps = false;
901-
return;
902-
}
903-
904-
/* If the live PL audio clock is not valid, fall back to PS clock. */
905-
disp->audio.clk = devm_clk_get(disp->dev, "dp_aud_clk");
906-
if (!IS_ERR(disp->audio.clk)) {
907-
disp->audio.clk_from_ps = true;
908-
return;
909-
}
910-
911-
dev_err(disp->dev, "audio disabled due to missing clock\n");
912-
}
913-
914891
/* -----------------------------------------------------------------------------
915892
* ZynqMP Display external functions for zynqmp_dp
916893
*/
@@ -929,32 +906,6 @@ void zynqmp_disp_handle_vblank(struct zynqmp_disp *disp)
929906
drm_crtc_handle_vblank(crtc);
930907
}
931908

932-
/**
933-
* zynqmp_disp_audio_enabled - If the audio is enabled
934-
* @disp: Display controller
935-
*
936-
* Return if the audio is enabled depending on the audio clock.
937-
*
938-
* Return: true if audio is enabled, or false.
939-
*/
940-
bool zynqmp_disp_audio_enabled(struct zynqmp_disp *disp)
941-
{
942-
return !!disp->audio.clk;
943-
}
944-
945-
/**
946-
* zynqmp_disp_get_audio_clk_rate - Get the current audio clock rate
947-
* @disp: Display controller
948-
*
949-
* Return: the current audio clock rate.
950-
*/
951-
unsigned int zynqmp_disp_get_audio_clk_rate(struct zynqmp_disp *disp)
952-
{
953-
if (zynqmp_disp_audio_enabled(disp))
954-
return 0;
955-
return clk_get_rate(disp->audio.clk);
956-
}
957-
958909
/**
959910
* zynqmp_disp_get_crtc_mask - Return the CRTC bit mask
960911
* @disp: Display controller
@@ -1408,7 +1359,8 @@ static void zynqmp_disp_enable(struct zynqmp_disp *disp)
14081359
zynqmp_disp_avbuf_enable(disp);
14091360
/* Choose clock source based on the DT clock handle. */
14101361
zynqmp_disp_avbuf_set_clocks_sources(disp, disp->dpsub->vid_clk_from_ps,
1411-
disp->audio.clk_from_ps, true);
1362+
disp->dpsub->aud_clk_from_ps,
1363+
true);
14121364
zynqmp_disp_avbuf_enable_channels(disp);
14131365
zynqmp_disp_avbuf_enable_audio(disp);
14141366

@@ -1669,8 +1621,6 @@ int zynqmp_disp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
16691621
if (IS_ERR(disp->audio.base))
16701622
return PTR_ERR(disp->audio.base);
16711623

1672-
zynqmp_disp_audio_init(disp);
1673-
16741624
ret = zynqmp_disp_create_layers(disp);
16751625
if (ret)
16761626
return ret;

drivers/gpu/drm/xlnx/zynqmp_disp.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ struct zynqmp_disp;
3131
struct zynqmp_dpsub;
3232

3333
void zynqmp_disp_handle_vblank(struct zynqmp_disp *disp);
34-
bool zynqmp_disp_audio_enabled(struct zynqmp_disp *disp);
35-
unsigned int zynqmp_disp_get_audio_clk_rate(struct zynqmp_disp *disp);
3634
uint32_t zynqmp_disp_get_crtc_mask(struct zynqmp_disp *disp);
3735

3836
int zynqmp_disp_drm_init(struct zynqmp_dpsub *dpsub);

drivers/gpu/drm/xlnx/zynqmp_dp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ static void zynqmp_dp_encoder_mode_set_stream(struct zynqmp_dp *dp,
12521252
reg = drm_dp_bw_code_to_link_rate(dp->mode.bw_code);
12531253
zynqmp_dp_write(dp, ZYNQMP_DP_MAIN_STREAM_N_VID, reg);
12541254
zynqmp_dp_write(dp, ZYNQMP_DP_MAIN_STREAM_M_VID, mode->clock);
1255-
rate = zynqmp_disp_get_audio_clk_rate(dp->dpsub->disp);
1255+
rate = zynqmp_dpsub_get_audio_clk_rate(dp->dpsub);
12561256
if (rate) {
12571257
dev_dbg(dp->dev, "Audio rate: %d\n", rate / 512);
12581258
zynqmp_dp_write(dp, ZYNQMP_DP_TX_N_AUD, reg);
@@ -1261,7 +1261,7 @@ static void zynqmp_dp_encoder_mode_set_stream(struct zynqmp_dp *dp,
12611261
}
12621262

12631263
/* Only 2 channel audio is supported now */
1264-
if (zynqmp_disp_audio_enabled(dp->dpsub->disp))
1264+
if (zynqmp_dpsub_audio_enabled(dp->dpsub))
12651265
zynqmp_dp_write(dp, ZYNQMP_DP_TX_AUDIO_CHANNELS, 1);
12661266

12671267
zynqmp_dp_write(dp, ZYNQMP_DP_USER_PIX_WIDTH, 1);
@@ -1372,7 +1372,7 @@ static void zynqmp_dp_bridge_atomic_enable(struct drm_bridge *bridge,
13721372
/* Enable the encoder */
13731373
dp->enabled = true;
13741374
zynqmp_dp_update_misc(dp);
1375-
if (zynqmp_disp_audio_enabled(dp->dpsub->disp))
1375+
if (zynqmp_dpsub_audio_enabled(dp->dpsub))
13761376
zynqmp_dp_write(dp, ZYNQMP_DP_TX_AUDIO_CONTROL, 1);
13771377
zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN, 0);
13781378
if (dp->status == connector_status_connected) {
@@ -1406,7 +1406,7 @@ static void zynqmp_dp_bridge_atomic_disable(struct drm_bridge *bridge,
14061406
drm_dp_dpcd_writeb(&dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
14071407
zynqmp_dp_write(dp, ZYNQMP_DP_TX_PHY_POWER_DOWN,
14081408
ZYNQMP_DP_TX_PHY_POWER_DOWN_ALL);
1409-
if (zynqmp_disp_audio_enabled(dp->dpsub->disp))
1409+
if (zynqmp_dpsub_audio_enabled(dp->dpsub))
14101410
zynqmp_dp_write(dp, ZYNQMP_DP_TX_AUDIO_CONTROL, 0);
14111411
pm_runtime_put_sync(dp->dev);
14121412
}

drivers/gpu/drm/xlnx/zynqmp_dpsub.c

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,36 @@ static const struct dev_pm_ops zynqmp_dpsub_pm_ops = {
196196
SET_SYSTEM_SLEEP_PM_OPS(zynqmp_dpsub_suspend, zynqmp_dpsub_resume)
197197
};
198198

199+
/* -----------------------------------------------------------------------------
200+
* DPSUB Configuration
201+
*/
202+
203+
/**
204+
* zynqmp_dpsub_audio_enabled - If the audio is enabled
205+
* @dpsub: DisplayPort subsystem
206+
*
207+
* Return if the audio is enabled depending on the audio clock.
208+
*
209+
* Return: true if audio is enabled, or false.
210+
*/
211+
bool zynqmp_dpsub_audio_enabled(struct zynqmp_dpsub *dpsub)
212+
{
213+
return !!dpsub->aud_clk;
214+
}
215+
216+
/**
217+
* zynqmp_dpsub_get_audio_clk_rate - Get the current audio clock rate
218+
* @dpsub: DisplayPort subsystem
219+
*
220+
* Return: the current audio clock rate.
221+
*/
222+
unsigned int zynqmp_dpsub_get_audio_clk_rate(struct zynqmp_dpsub *dpsub)
223+
{
224+
if (zynqmp_dpsub_audio_enabled(dpsub))
225+
return 0;
226+
return clk_get_rate(dpsub->aud_clk);
227+
}
228+
199229
/* -----------------------------------------------------------------------------
200230
* Probe & Remove
201231
*/
@@ -214,14 +244,16 @@ static int zynqmp_dpsub_init_clocks(struct zynqmp_dpsub *dpsub)
214244
return ret;
215245
}
216246

217-
/* Try the live PL video clock */
247+
/*
248+
* Try the live PL video clock, and fall back to the PS clock if the
249+
* live PL video clock isn't valid.
250+
*/
218251
dpsub->vid_clk = devm_clk_get(dpsub->dev, "dp_live_video_in_clk");
219252
if (!IS_ERR(dpsub->vid_clk))
220253
dpsub->vid_clk_from_ps = false;
221254
else if (PTR_ERR(dpsub->vid_clk) == -EPROBE_DEFER)
222255
return PTR_ERR(dpsub->vid_clk);
223256

224-
/* If the live PL video clock is not valid, fall back to PS clock */
225257
if (IS_ERR_OR_NULL(dpsub->vid_clk)) {
226258
dpsub->vid_clk = devm_clk_get(dpsub->dev, "dp_vtc_pixel_clk_in");
227259
if (IS_ERR(dpsub->vid_clk)) {
@@ -231,6 +263,24 @@ static int zynqmp_dpsub_init_clocks(struct zynqmp_dpsub *dpsub)
231263
dpsub->vid_clk_from_ps = true;
232264
}
233265

266+
/*
267+
* Try the live PL audio clock, and fall back to the PS clock if the
268+
* live PL audio clock isn't valid. Missing audio clock disables audio
269+
* but isn't an error.
270+
*/
271+
dpsub->aud_clk = devm_clk_get(dpsub->dev, "dp_live_audio_aclk");
272+
if (!IS_ERR(dpsub->aud_clk)) {
273+
dpsub->aud_clk_from_ps = false;
274+
return 0;
275+
}
276+
277+
dpsub->aud_clk = devm_clk_get(dpsub->dev, "dp_aud_clk");
278+
if (!IS_ERR(dpsub->aud_clk)) {
279+
dpsub->aud_clk_from_ps = true;
280+
return 0;
281+
}
282+
283+
dev_info(dpsub->dev, "audio disabled due to missing clock\n");
234284
return 0;
235285
}
236286

drivers/gpu/drm/xlnx/zynqmp_dpsub.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ enum zynqmp_dpsub_format {
3535
* @apb_clk: The APB clock
3636
* @vid_clk: Video clock
3737
* @vid_clk_from_ps: True of the video clock comes from PS, false from PL
38+
* @aud_clk: Audio clock
39+
* @aud_clk_from_ps: True of the audio clock comes from PS, false from PL
3840
* @encoder: The dummy DRM encoder
3941
* @bridge: The DP encoder bridge
4042
* @disp: The display controller
@@ -48,6 +50,8 @@ struct zynqmp_dpsub {
4850
struct clk *apb_clk;
4951
struct clk *vid_clk;
5052
bool vid_clk_from_ps;
53+
struct clk *aud_clk;
54+
bool aud_clk_from_ps;
5155

5256
struct drm_encoder encoder;
5357
struct drm_bridge *bridge;
@@ -63,4 +67,7 @@ static inline struct zynqmp_dpsub *to_zynqmp_dpsub(struct drm_device *drm)
6367
return container_of(drm, struct zynqmp_dpsub, drm);
6468
}
6569

70+
bool zynqmp_dpsub_audio_enabled(struct zynqmp_dpsub *dpsub);
71+
unsigned int zynqmp_dpsub_get_audio_clk_rate(struct zynqmp_dpsub *dpsub);
72+
6673
#endif /* _ZYNQMP_DPSUB_H_ */

0 commit comments

Comments
 (0)