31
31
* encoder block has CEC support.
32
32
*/
33
33
34
+ #include <drm/display/drm_hdmi_audio_helper.h>
34
35
#include <drm/display/drm_hdmi_helper.h>
35
36
#include <drm/display/drm_hdmi_state_helper.h>
36
37
#include <drm/display/drm_scdc_helper.h>
@@ -584,6 +585,7 @@ static const struct drm_connector_helper_funcs vc4_hdmi_connector_helper_funcs =
584
585
};
585
586
586
587
static const struct drm_connector_hdmi_funcs vc4_hdmi_hdmi_connector_funcs ;
588
+ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs ;
587
589
588
590
static int vc4_hdmi_connector_init (struct drm_device * dev ,
589
591
struct vc4_hdmi * vc4_hdmi )
@@ -609,6 +611,12 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
609
611
if (ret )
610
612
return ret ;
611
613
614
+ ret = drm_connector_hdmi_audio_init (connector , dev -> dev ,
615
+ & vc4_hdmi_audio_funcs ,
616
+ 8 , false, -1 );
617
+ if (ret )
618
+ return ret ;
619
+
612
620
drm_connector_helper_add (connector , & vc4_hdmi_connector_helper_funcs );
613
621
614
622
/*
@@ -1921,9 +1929,9 @@ static bool vc4_hdmi_audio_can_stream(struct vc4_hdmi *vc4_hdmi)
1921
1929
return true;
1922
1930
}
1923
1931
1924
- static int vc4_hdmi_audio_startup (struct device * dev , void * data )
1932
+ static int vc4_hdmi_audio_startup (struct drm_connector * connector )
1925
1933
{
1926
- struct vc4_hdmi * vc4_hdmi = dev_get_drvdata ( dev );
1934
+ struct vc4_hdmi * vc4_hdmi = connector_to_vc4_hdmi ( connector );
1927
1935
struct drm_device * drm = vc4_hdmi -> connector .dev ;
1928
1936
unsigned long flags ;
1929
1937
int ret = 0 ;
@@ -1985,9 +1993,9 @@ static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi)
1985
1993
spin_unlock_irqrestore (& vc4_hdmi -> hw_lock , flags );
1986
1994
}
1987
1995
1988
- static void vc4_hdmi_audio_shutdown (struct device * dev , void * data )
1996
+ static void vc4_hdmi_audio_shutdown (struct drm_connector * connector )
1989
1997
{
1990
- struct vc4_hdmi * vc4_hdmi = dev_get_drvdata ( dev );
1998
+ struct vc4_hdmi * vc4_hdmi = connector_to_vc4_hdmi ( connector );
1991
1999
struct drm_device * drm = vc4_hdmi -> connector .dev ;
1992
2000
unsigned long flags ;
1993
2001
int idx ;
@@ -2057,13 +2065,12 @@ static int sample_rate_to_mai_fmt(int samplerate)
2057
2065
}
2058
2066
2059
2067
/* HDMI audio codec callbacks */
2060
- static int vc4_hdmi_audio_prepare (struct device * dev , void * data ,
2068
+ static int vc4_hdmi_audio_prepare (struct drm_connector * connector ,
2061
2069
struct hdmi_codec_daifmt * daifmt ,
2062
2070
struct hdmi_codec_params * params )
2063
2071
{
2064
- struct vc4_hdmi * vc4_hdmi = dev_get_drvdata ( dev );
2072
+ struct vc4_hdmi * vc4_hdmi = connector_to_vc4_hdmi ( connector );
2065
2073
struct drm_device * drm = vc4_hdmi -> connector .dev ;
2066
- struct drm_connector * connector = & vc4_hdmi -> connector ;
2067
2074
struct vc4_dev * vc4 = to_vc4_dev (drm );
2068
2075
unsigned int sample_rate = params -> sample_rate ;
2069
2076
unsigned int channels = params -> channels ;
@@ -2075,7 +2082,7 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data,
2075
2082
int ret = 0 ;
2076
2083
int idx ;
2077
2084
2078
- dev_dbg (dev , "%s: %u Hz, %d bit, %d channels\n" , __func__ ,
2085
+ dev_dbg (& vc4_hdmi -> pdev -> dev , "%s: %u Hz, %d bit, %d channels\n" , __func__ ,
2079
2086
sample_rate , params -> sample_width , channels );
2080
2087
2081
2088
mutex_lock (& vc4_hdmi -> mutex );
@@ -2214,48 +2221,19 @@ static const struct snd_dmaengine_pcm_config pcm_conf = {
2214
2221
.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config ,
2215
2222
};
2216
2223
2217
- static int vc4_hdmi_audio_get_eld (struct device * dev , void * data ,
2218
- uint8_t * buf , size_t len )
2219
- {
2220
- struct vc4_hdmi * vc4_hdmi = dev_get_drvdata (dev );
2221
- struct drm_connector * connector = & vc4_hdmi -> connector ;
2222
-
2223
- mutex_lock (& connector -> eld_mutex );
2224
- memcpy (buf , connector -> eld , min (sizeof (connector -> eld ), len ));
2225
- mutex_unlock (& connector -> eld_mutex );
2226
-
2227
- return 0 ;
2228
- }
2229
-
2230
- static const struct hdmi_codec_ops vc4_hdmi_codec_ops = {
2231
- .get_eld = vc4_hdmi_audio_get_eld ,
2224
+ static const struct drm_connector_hdmi_audio_funcs vc4_hdmi_audio_funcs = {
2225
+ .startup = vc4_hdmi_audio_startup ,
2232
2226
.prepare = vc4_hdmi_audio_prepare ,
2233
- .audio_shutdown = vc4_hdmi_audio_shutdown ,
2234
- .audio_startup = vc4_hdmi_audio_startup ,
2235
- };
2236
-
2237
- static struct hdmi_codec_pdata vc4_hdmi_codec_pdata = {
2238
- .ops = & vc4_hdmi_codec_ops ,
2239
- .max_i2s_channels = 8 ,
2240
- .i2s = 1 ,
2227
+ .shutdown = vc4_hdmi_audio_shutdown ,
2241
2228
};
2242
2229
2243
- static void vc4_hdmi_audio_codec_release (void * ptr )
2244
- {
2245
- struct vc4_hdmi * vc4_hdmi = ptr ;
2246
-
2247
- platform_device_unregister (vc4_hdmi -> audio .codec_pdev );
2248
- vc4_hdmi -> audio .codec_pdev = NULL ;
2249
- }
2250
-
2251
2230
static int vc4_hdmi_audio_init (struct vc4_hdmi * vc4_hdmi )
2252
2231
{
2253
2232
const struct vc4_hdmi_register * mai_data =
2254
2233
& vc4_hdmi -> variant -> registers [HDMI_MAI_DATA ];
2255
2234
struct snd_soc_dai_link * dai_link = & vc4_hdmi -> audio .link ;
2256
2235
struct snd_soc_card * card = & vc4_hdmi -> audio .card ;
2257
2236
struct device * dev = & vc4_hdmi -> pdev -> dev ;
2258
- struct platform_device * codec_pdev ;
2259
2237
const __be32 * addr ;
2260
2238
int index , len ;
2261
2239
int ret ;
@@ -2348,20 +2326,6 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
2348
2326
return ret ;
2349
2327
}
2350
2328
2351
- codec_pdev = platform_device_register_data (dev , HDMI_CODEC_DRV_NAME ,
2352
- PLATFORM_DEVID_AUTO ,
2353
- & vc4_hdmi_codec_pdata ,
2354
- sizeof (vc4_hdmi_codec_pdata ));
2355
- if (IS_ERR (codec_pdev )) {
2356
- dev_err (dev , "Couldn't register the HDMI codec: %ld\n" , PTR_ERR (codec_pdev ));
2357
- return PTR_ERR (codec_pdev );
2358
- }
2359
- vc4_hdmi -> audio .codec_pdev = codec_pdev ;
2360
-
2361
- ret = devm_add_action_or_reset (dev , vc4_hdmi_audio_codec_release , vc4_hdmi );
2362
- if (ret )
2363
- return ret ;
2364
-
2365
2329
dai_link -> cpus = & vc4_hdmi -> audio .cpu ;
2366
2330
dai_link -> codecs = & vc4_hdmi -> audio .codec ;
2367
2331
dai_link -> platforms = & vc4_hdmi -> audio .platform ;
@@ -2374,7 +2338,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
2374
2338
dai_link -> stream_name = "MAI PCM" ;
2375
2339
dai_link -> codecs -> dai_name = "i2s-hifi" ;
2376
2340
dai_link -> cpus -> dai_name = dev_name (dev );
2377
- dai_link -> codecs -> name = dev_name (& codec_pdev -> dev );
2341
+ dai_link -> codecs -> name = dev_name (& vc4_hdmi -> connector . hdmi_audio . codec_pdev -> dev );
2378
2342
dai_link -> platforms -> name = dev_name (dev );
2379
2343
2380
2344
card -> dai_link = dai_link ;
0 commit comments