Skip to content

Commit

Permalink
drm/bridge: dw-hdmi: Move vmalloc PCM buffer management into the driver
Browse files Browse the repository at this point in the history
The dw-hdmi drm bridge driver is the only one who still uses the ALSA
vmalloc helper API functions.  A previous attempt to change the way of
buffer management wasn't taken for this legacy stuff, as we had little
chance for test and some risk of major breaking.
Instead, this patch moves the vmalloc buffer stuff into the dw-hdmi
driver code itself, so that we can drop them from ALSA core code
afterwards.

There should be no functional changes.

Link: https://lore.kernel.org/20191210154536.29819-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807152725.18948-2-tiwai@suse.de
  • Loading branch information
tiwai committed Aug 27, 2024
1 parent f7b1633 commit 002353a
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/vmalloc.h>
#include <drm/bridge/dw_hdmi.h>
#include <drm/drm_edid.h>

Expand Down Expand Up @@ -388,15 +389,36 @@ static int dw_hdmi_close(struct snd_pcm_substream *substream)

static int dw_hdmi_hw_free(struct snd_pcm_substream *substream)
{
return snd_pcm_lib_free_vmalloc_buffer(substream);
struct snd_pcm_runtime *runtime = substream->runtime;

vfree(runtime->dma_area);
runtime->dma_area = NULL;
return 0;
}

static int dw_hdmi_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_pcm_runtime *runtime = substream->runtime;
size_t size = params_buffer_bytes(params);

/* Allocate the PCM runtime buffer, which is exposed to userspace. */
return snd_pcm_lib_alloc_vmalloc_buffer(substream,
params_buffer_bytes(params));
if (runtime->dma_area) {
if (runtime->dma_bytes >= size)
return 0; /* already large enough */
vfree(runtime->dma_area);
}
runtime->dma_area = vzalloc(size);
if (!runtime->dma_area)
return -ENOMEM;
runtime->dma_bytes = size;
return 1;
}

static struct page *dw_hdmi_get_page(struct snd_pcm_substream *substream,
unsigned long offset)
{
return vmalloc_to_page(substream->runtime->dma_area + offset);
}

static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
Expand Down Expand Up @@ -515,7 +537,7 @@ static const struct snd_pcm_ops snd_dw_hdmi_ops = {
.prepare = dw_hdmi_prepare,
.trigger = dw_hdmi_trigger,
.pointer = dw_hdmi_pointer,
.page = snd_pcm_lib_get_vmalloc_page,
.page = dw_hdmi_get_page,
};

static int snd_dw_hdmi_probe(struct platform_device *pdev)
Expand Down

0 comments on commit 002353a

Please sign in to comment.