Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build on kernel v6.12 #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bus/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ static struct device_type gip_client_type = {
.release = gip_client_release,
};

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
static int gip_bus_match(struct device *dev, struct device_driver *driver)
#else
static int gip_bus_match(struct device *dev, const struct device_driver *driver)
#endif
{
struct gip_client *client;
struct gip_driver *drv;
Expand Down
30 changes: 26 additions & 4 deletions driver/headset.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <linux/module.h>
#include <linux/hrtimer.h>
#include <linux/vmalloc.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/pcm.h>
Expand Down Expand Up @@ -90,13 +91,34 @@ static int gip_headset_pcm_close(struct snd_pcm_substream *sub)
static int gip_headset_pcm_hw_params(struct snd_pcm_substream *sub,
struct snd_pcm_hw_params *params)
{
return snd_pcm_lib_alloc_vmalloc_buffer(sub,
params_buffer_bytes(params));
struct snd_pcm_runtime *runtime = sub->runtime;
size_t size = 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 int gip_headset_pcm_hw_free(struct snd_pcm_substream *sub)
{
return snd_pcm_lib_free_vmalloc_buffer(sub);
struct snd_pcm_runtime *runtime = sub->runtime;

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

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

static int gip_headset_pcm_prepare(struct snd_pcm_substream *sub)
Expand Down Expand Up @@ -157,7 +179,7 @@ static const struct snd_pcm_ops gip_headset_pcm_ops = {
.prepare = gip_headset_pcm_prepare,
.trigger = gip_headset_pcm_trigger,
.pointer = gip_headset_pcm_pointer,
.page = snd_pcm_lib_get_vmalloc_page,
.page = gip_headset_pcm_get_page,
};

static bool gip_headset_advance_pointer(struct gip_headset_stream *stream,
Expand Down