mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
a6ed68d646
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJd3YntAAoJEAx081l5xIa+dcQP/ikABkpm+q23FLKteRpL1rtX xqlg5+KHW+YVCDls2BrINF6vYzyisoa8fNPlKMmOHse/IgMhFe9vBbCj1KQQOUR1 apNycI1wrcw/mn2WDikoIcF6C5cjqK9YVknnYoM6HnF1VmpGd1ecSGrOHrunEkrK cMAWYIeqWGU8Gj/HUOitAFpLWFUMNle0BJuRoGLcoMusgS8yuCIEcpNzRhgL8fvJ bW4imuyv24OjPoQzbKD0oQ0VIP86H0eM4LIeGZ2uyK/BSPKmMDqI4z4isUheS7RL w4a6BdobMIdhew5dBXS0LsUJ3JniVJdHy123q9KgpmQAhGpiNoLT6BujfoUTUeWx Mu0vM8Xmv9n4npdBYC+fLEFQXYJlu9uBA490jP84Kz6Fg1c6GyBebDY7/c2O4Zmg 7pvygmUF6boD6v2sIC/3161crgwU4g8zoxm2V4i9naxes2QB13LiEuJWlaI/FdxY fd3zpglFGdoF1ThNne4QDh6gMKpXvjITyu/QxZeZ67Dt6i0Aqw9cRGHSpiVhYyDc cx2hAp+rDvUi5SHkJKFpVImjB2DDn2xUG2uFMHz0cy9wNg203L3fRDi0hVtnM1+W VpCxyLs2Upz6kEjDRVsfMZ9chCcWAWpVuKhtuuMUDw/IKnbP3uV8kzgJpVpaRVkD 76s5uYWHHBlk1IVlkOUP =Hj7G -----END PGP SIGNATURE----- Merge tag 'drm-next-2019-11-27' of git://anongit.freedesktop.org/drm/drm Pull drm updates from Dave Airlie: "Lots of stuff in here, though it hasn't been too insane this merge apart from dealing with the security fun. uapi: - export different colorspace properties on DP vs HDMI - new fourcc for ARM 16x16 block format - syncobj: allow querying last submitted timeline value - DRM_FORMAT_BIG_ENDIAN defined as unsigned core: - allow using gem vma manager in ttm - connector/encoder/bridge doc fixes - allow more than 3 encoders for a connector - displayport mst suspend/resume reprobing support - vram lazy unmapping, uniform vram mm and gem vram - edid cleanups + AVI informframe bar info - displayport helpers - dpcd parser added dp_cec: - Allow a connector to be associated with a cec device ttm: - pipelining with no_gpu_wait fix - always keep BOs on the LRU sched: - allow free_job routine to sleep i915: - Block userptr from mappable GTT - i915 perf uapi versioning - OA stream dynamic reconfiguration - make context persistence optional - introduce DRM_I915_UNSTABLE Kconfig - add fake lmem testing under unstable - BT.2020 support for DP MSA - struct mutex elimination - Tigerlake display/PLL/power management improvements - Jasper Lake PCH support - refactor PMU for multiple GPUs - Icelake firmware update - Split out vga + switcheroo code amdgpu: - implement dma-buf import/export without helpers - vega20 RAS enablement - DC i2c over aux fixes - renoir GPU reset - DC HDCP support - BACO support for CI/VI asics - MSI-X support - Arcturus EEPROM support - Arcturus VCN encode support - VCN dynamic powergating on RV/RV2 amdkfd: - add navi12/14/renoir support to kfd radeon: - SI dpm fix ported from amdgpu - fix bad DMA on ppc platforms gma500: - memory leak fixes qxl: - convert to new gem mmap exynos: - build warning fix komeda: - add aclk sysfs attribute v3d: - userspace cleanup uapi change i810: - fix for underflow in dispatch ioctls ast: - refactor show_cursor mgag200: - refactor show_cursor arcgpu: - encoder finding improvements mediatek: - mipi_tx, dsi and partial crtc support for MT8183 SoC - rotation support meson: - add suspend/resume support omap: - misc refactors tegra: - DisplayPort support for Tegra 210, 186 and 194. - IOMMU-backed DMA API fixes panfrost: - fix lockdep issue - simplify devfreq integration rcar-du: - R8A774B1 SoC support - fixes for H2 ES2.0 sun4i: - vcc-dsi regulator support virtio-gpu: - vmexit vs spinlock fix - move to gem shmem helpers - handle large command buffers with cma" * tag 'drm-next-2019-11-27' of git://anongit.freedesktop.org/drm/drm: (1855 commits) drm/amdgpu: invalidate mmhub semaphore workaround in gmc9/gmc10 drm/amdgpu: initialize vm_inv_eng0_sem for gfxhub and mmhub drm/amd/amdgpu/sriov skip RLCG s/r list for arcturus VF. drm/amd/amdgpu/sriov temporarily skip ras,dtm,hdcp for arcturus VF drm/amdgpu/gfx10: re-init clear state buffer after gpu reset merge fix for "ftrace: Rework event_create_dir()" drm/amdgpu: Update Arcturus golden registers drm/amdgpu/gfx10: fix out-of-bound mqd_backup array access drm/amdgpu/gfx10: explicitly wait for cp idle after halt/unhalt Revert "drm/amd/display: enable S/G for RAVEN chip" drm/amdgpu: disable gfxoff on original raven drm/amdgpu: remove experimental flag for Navi14 drm/amdgpu: disable gfxoff when using register read interface drm/amdgpu/powerplay: properly set PP_GFXOFF_MASK (v2) drm/amdgpu: fix bad DMA from INTERRUPT_CNTL2 drm/radeon: fix bad DMA from INTERRUPT_CNTL2 drm/amd/display: Fix debugfs on MST connectors drm/amdgpu/nv: add asic func for fetching vbios from rom directly drm/amdgpu: put flush_delayed_work at first drm/amdgpu/vcn2.5: fix the enc loop with hw fini ...
233 lines
5.5 KiB
C
233 lines
5.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* dw-hdmi-i2s-audio.c
|
|
*
|
|
* Copyright (c) 2017 Renesas Solutions Corp.
|
|
* Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
|
*/
|
|
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/module.h>
|
|
|
|
#include <drm/bridge/dw_hdmi.h>
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <sound/hdmi-codec.h>
|
|
|
|
#include "dw-hdmi.h"
|
|
#include "dw-hdmi-audio.h"
|
|
|
|
#define DRIVER_NAME "dw-hdmi-i2s-audio"
|
|
|
|
static inline void hdmi_write(struct dw_hdmi_i2s_audio_data *audio,
|
|
u8 val, int offset)
|
|
{
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
|
|
audio->write(hdmi, val, offset);
|
|
}
|
|
|
|
static inline u8 hdmi_read(struct dw_hdmi_i2s_audio_data *audio, int offset)
|
|
{
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
|
|
return audio->read(hdmi, offset);
|
|
}
|
|
|
|
static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
|
|
struct hdmi_codec_daifmt *fmt,
|
|
struct hdmi_codec_params *hparms)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = data;
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
u8 conf0 = 0;
|
|
u8 conf1 = 0;
|
|
u8 inputclkfs = 0;
|
|
|
|
/* it cares I2S only */
|
|
if (fmt->bit_clk_master | fmt->frame_clk_master) {
|
|
dev_err(dev, "unsupported clock settings\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* Reset the FIFOs before applying new params */
|
|
hdmi_write(audio, HDMI_AUD_CONF0_SW_RESET, HDMI_AUD_CONF0);
|
|
hdmi_write(audio, (u8)~HDMI_MC_SWRSTZ_I2SSWRST_REQ, HDMI_MC_SWRSTZ);
|
|
|
|
inputclkfs = HDMI_AUD_INPUTCLKFS_64FS;
|
|
conf0 = (HDMI_AUD_CONF0_I2S_SELECT | HDMI_AUD_CONF0_I2S_EN0);
|
|
|
|
/* Enable the required i2s lanes */
|
|
switch (hparms->channels) {
|
|
case 7 ... 8:
|
|
conf0 |= HDMI_AUD_CONF0_I2S_EN3;
|
|
/* Fall-thru */
|
|
case 5 ... 6:
|
|
conf0 |= HDMI_AUD_CONF0_I2S_EN2;
|
|
/* Fall-thru */
|
|
case 3 ... 4:
|
|
conf0 |= HDMI_AUD_CONF0_I2S_EN1;
|
|
/* Fall-thru */
|
|
}
|
|
|
|
switch (hparms->sample_width) {
|
|
case 16:
|
|
conf1 = HDMI_AUD_CONF1_WIDTH_16;
|
|
break;
|
|
case 24:
|
|
case 32:
|
|
conf1 = HDMI_AUD_CONF1_WIDTH_24;
|
|
break;
|
|
}
|
|
|
|
switch (fmt->fmt) {
|
|
case HDMI_I2S:
|
|
conf1 |= HDMI_AUD_CONF1_MODE_I2S;
|
|
break;
|
|
case HDMI_RIGHT_J:
|
|
conf1 |= HDMI_AUD_CONF1_MODE_RIGHT_J;
|
|
break;
|
|
case HDMI_LEFT_J:
|
|
conf1 |= HDMI_AUD_CONF1_MODE_LEFT_J;
|
|
break;
|
|
case HDMI_DSP_A:
|
|
conf1 |= HDMI_AUD_CONF1_MODE_BURST_1;
|
|
break;
|
|
case HDMI_DSP_B:
|
|
conf1 |= HDMI_AUD_CONF1_MODE_BURST_2;
|
|
break;
|
|
default:
|
|
dev_err(dev, "unsupported format\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
|
|
dw_hdmi_set_channel_status(hdmi, hparms->iec.status);
|
|
dw_hdmi_set_channel_count(hdmi, hparms->channels);
|
|
dw_hdmi_set_channel_allocation(hdmi, hparms->cea.channel_allocation);
|
|
|
|
hdmi_write(audio, inputclkfs, HDMI_AUD_INPUTCLKFS);
|
|
hdmi_write(audio, conf0, HDMI_AUD_CONF0);
|
|
hdmi_write(audio, conf1, HDMI_AUD_CONF1);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int dw_hdmi_i2s_audio_startup(struct device *dev, void *data)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = data;
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
|
|
dw_hdmi_audio_enable(hdmi);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = data;
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
|
|
dw_hdmi_audio_disable(hdmi);
|
|
}
|
|
|
|
static int dw_hdmi_i2s_get_eld(struct device *dev, void *data, uint8_t *buf,
|
|
size_t len)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = data;
|
|
|
|
memcpy(buf, audio->eld, min_t(size_t, MAX_ELD_BYTES, len));
|
|
return 0;
|
|
}
|
|
|
|
static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
|
|
struct device_node *endpoint)
|
|
{
|
|
struct of_endpoint of_ep;
|
|
int ret;
|
|
|
|
ret = of_graph_parse_endpoint(endpoint, &of_ep);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
/*
|
|
* HDMI sound should be located as reg = <2>
|
|
* Then, it is sound port 0
|
|
*/
|
|
if (of_ep.port == 2)
|
|
return 0;
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
static int dw_hdmi_i2s_hook_plugged_cb(struct device *dev, void *data,
|
|
hdmi_codec_plugged_cb fn,
|
|
struct device *codec_dev)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = data;
|
|
struct dw_hdmi *hdmi = audio->hdmi;
|
|
|
|
return dw_hdmi_set_plugged_cb(hdmi, fn, codec_dev);
|
|
}
|
|
|
|
static struct hdmi_codec_ops dw_hdmi_i2s_ops = {
|
|
.hw_params = dw_hdmi_i2s_hw_params,
|
|
.audio_startup = dw_hdmi_i2s_audio_startup,
|
|
.audio_shutdown = dw_hdmi_i2s_audio_shutdown,
|
|
.get_eld = dw_hdmi_i2s_get_eld,
|
|
.get_dai_id = dw_hdmi_i2s_get_dai_id,
|
|
.hook_plugged_cb = dw_hdmi_i2s_hook_plugged_cb,
|
|
};
|
|
|
|
static int snd_dw_hdmi_probe(struct platform_device *pdev)
|
|
{
|
|
struct dw_hdmi_i2s_audio_data *audio = pdev->dev.platform_data;
|
|
struct platform_device_info pdevinfo;
|
|
struct hdmi_codec_pdata pdata;
|
|
struct platform_device *platform;
|
|
|
|
pdata.ops = &dw_hdmi_i2s_ops;
|
|
pdata.i2s = 1;
|
|
pdata.max_i2s_channels = 8;
|
|
pdata.data = audio;
|
|
|
|
memset(&pdevinfo, 0, sizeof(pdevinfo));
|
|
pdevinfo.parent = pdev->dev.parent;
|
|
pdevinfo.id = PLATFORM_DEVID_AUTO;
|
|
pdevinfo.name = HDMI_CODEC_DRV_NAME;
|
|
pdevinfo.data = &pdata;
|
|
pdevinfo.size_data = sizeof(pdata);
|
|
pdevinfo.dma_mask = DMA_BIT_MASK(32);
|
|
|
|
platform = platform_device_register_full(&pdevinfo);
|
|
if (IS_ERR(platform))
|
|
return PTR_ERR(platform);
|
|
|
|
dev_set_drvdata(&pdev->dev, platform);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int snd_dw_hdmi_remove(struct platform_device *pdev)
|
|
{
|
|
struct platform_device *platform = dev_get_drvdata(&pdev->dev);
|
|
|
|
platform_device_unregister(platform);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver snd_dw_hdmi_driver = {
|
|
.probe = snd_dw_hdmi_probe,
|
|
.remove = snd_dw_hdmi_remove,
|
|
.driver = {
|
|
.name = DRIVER_NAME,
|
|
},
|
|
};
|
|
module_platform_driver(snd_dw_hdmi_driver);
|
|
|
|
MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
|
|
MODULE_DESCRIPTION("Synopsis Designware HDMI I2S ALSA SoC interface");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_ALIAS("platform:" DRIVER_NAME);
|