dde_bsd: update audio driver to OpenBSD 7.1

This commit updates the driver from version 6.6 to 7.1. In contrast
to the old driver the new one will now probe all available HDA devices
and will drive the first usable one, e.g.:

```
[init -> audio_drv] azalia0 [8086:160c]
[init -> audio_drv] :
[init -> audio_drv] azalia0: no supported codecs
[init -> audio_drv] azalia1 [8086:9ca0]
[init -> audio_drv] :
[init -> audio_drv] azalia1: codecs: Realtek ALC292
[init -> audio_drv] audio0 at azalia1
```

Fixes #4629.
This commit is contained in:
Josef Söntgen
2022-09-30 19:35:01 +00:00
committed by Christian Helmuth
parent 3186e47807
commit e0f5cdacf0
17 changed files with 235 additions and 210 deletions

View File

@ -45,6 +45,11 @@ struct cfdata cfdata[] = {
struct device pci_bus = { DV_DULL, { 0, 0 }, 0, 0, { 'p', 'c', 'i', '0'}, 0, 0, 0 };
/* global unit counter */
static int dv_unit;
/**
* This function is our little helper that matches and attaches
* the driver to the device.
@ -72,12 +77,23 @@ int probe_cfdata(struct pci_attach_args *pa)
M_DEVBUF, M_NOWAIT|M_ZERO);
dev->dv_cfdata = cf;
dev->dv_unit = dv_unit++;
snprintf(dev->dv_xname, sizeof(dev->dv_xname), "%s%d", cd->cd_name,
dev->dv_unit);
printf("%s at %s\n", dev->dv_xname, pci_bus.dv_xname);
printf("%s [%x:%x]\n", dev->dv_xname,
pa->pa_id & 0xffffu, (pa->pa_id >> 16u) & 0xffffu);
ca->ca_attach(&pci_bus, dev, pa);
/*
* The contrib code is patched to set the dv_ref when the
* driver attached successfully.
*/
if (!pci_bus.dv_ref) {
free(dev, M_DEVBUF, ca->ca_devsize);
return 0;
}
return 1;
}
}

View File

@ -33,8 +33,8 @@
extern struct cfdriver audio_cd;
static dev_t const adev = 0x00; /* audio0 (minor nr 0) */
static dev_t const mdev = 0x10; /* mixer0 (minor nr 16) */
static dev_t const adev = 0x00; /* /dev/audio0 */
static dev_t const mdev = 0xc0; /* /dev/audioctl */
static bool adev_usuable = false;
@ -327,6 +327,11 @@ static bool open_audio_device(dev_t dev)
return false;
int err = audioopen(dev, FWRITE|FREAD, 0 /* ifmt */, 0 /* proc */);
/* try to open playback only, if capturing potentially failed */
if (err == ENODEV)
err = audioopen(dev, FWRITE, 0 /* ifmt */, 0 /* proc */);
if (err)
return false;

View File

@ -46,21 +46,35 @@ DUMMY name(void) { \
DUMMY_RET(1, pci_intr_map_msi) /* do not support MSI API */
DUMMY_RET(0, pci_intr_string)
DUMMY(0, bus_dmamap_unload)
DUMMY(0, bus_dmamem_mmap)
DUMMY(0, bus_dmamem_unmap)
DUMMY(0, bus_space_unmap)
DUMMY(0, config_activate_children)
DUMMY(0, config_deactivate)
DUMMY(0, config_detach)
DUMMY(0, config_detach_children)
DUMMY(0, cpu_info_primary)
DUMMY(0, device_unref)
DUMMY(0, klist_free)
DUMMY(0, klist_init_mutex)
DUMMY(0, klist_insert_locked)
DUMMY(0, klist_invalidate)
DUMMY(0, klist_remove)
DUMMY(0, klist_remove_locked)
DUMMY(0, knote_modify)
DUMMY(0, knote_process)
DUMMY(0, pci_findvendor)
DUMMY(0, pci_intr_disestablish)
DUMMY(0, pci_set_powerstate)
DUMMY(0, psignal)
DUMMY(0, selrecord)
DUMMY(0, selwakeup)
DUMMY(0, softintr_disestablish)
DUMMY(0, softintr_schedule)
DUMMY(0, tsleep)
DUMMY(0, tsleep_nsec)
DUMMY(0, vdevgone)
DUMMY(0, device_unref)
DUMMY(1, softintr_establish)
} /* extern "C" */

View File

@ -65,6 +65,43 @@ typedef signed long long off_t;
#define minor(x) ((int32_t)((x) & 0xff) | (((x) & 0xffff0000) >> 8))
/*******************
** machine/cpu.h **
*******************/
struct cpu_info { };
extern struct cpu_info cpu_info_primary;
#define curcpu() (&cpu_info_primary)
/*********************
** machine/mutex.h **
*********************/
#define MUTEX_INITIALIZER(ipl) { 0, (ipl), 0, NULL }
#define MUTEX_ASSERT_UNLOCK(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s\n", (mtx), __func__); \
} while (0)
#define MUTEX_ASSERT_LOCKED(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s\n", (mtx), __func__); \
} while (0)
#define MUTEX_ASSERT_UNLOCKED(mtx) do { \
if ((mtx)->mtx_owner == curcpu()) \
panic("mutex %p held in %s\n", (mtx), __func__); \
} while (0)
struct mutex
{
volatile int mtx_lock;
int mtx_wantipl; /* interrupt priority level */
int mtx_oldipl;
void *mtx_owner;
};
/*****************
** sys/errno.h **
*****************/
@ -215,12 +252,17 @@ struct kevent
struct knote;
SLIST_HEAD(klist, knote);
#define FILTEROP_ISFD 0x00000001
#define FILTEROP_MPSAFE 0x00000002
struct filterops
{
int f_isfd;
int f_flags;
int (*f_attach)(struct knote*);
void (*f_detach)(struct knote*);
int (*f_event)(struct knote*, long);
int (*f_modify)(struct kevent *, struct knote *);
int (*f_process)(struct knote *, struct kevent *);
};
struct knote
@ -233,6 +275,15 @@ struct knote
void *kn_hook;
};
int knote_modify(const struct kevent *kev, struct knote *kn);
int knote_process(struct knote *kn, struct kevent *kev);
extern void klist_free(struct klist *);
extern void klist_init_mutex(struct klist *, struct mutex *);
extern void klist_insert(struct klist *, struct knote *);
extern void klist_invalidate(struct klist *);
extern void klist_remove(struct klist *, struct knote *);
/*******************
** sys/selinfo.h **
@ -247,43 +298,6 @@ void selrecord(struct proc *selector, struct selinfo *);
void selwakeup(struct selinfo *);
/*******************
** machine/cpu.h **
*******************/
struct cpu_info { };
extern struct cpu_info cpu_info_primary;
#define curcpu() (&cpu_info_primary)
/*********************
** machine/mutex.h **
*********************/
#define MUTEX_INITIALIZER(ipl) { 0, (ipl), 0, NULL }
#define MUTEX_ASSERT_UNLOCK(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s\n", (mtx), __func__); \
} while (0)
#define MUTEX_ASSERT_LOCKED(mtx) do { \
if ((mtx)->mtx_owner != curcpu()) \
panic("mutex %p not held in %s\n", (mtx), __func__); \
} while (0)
#define MUTEX_ASSERT_UNLOCKED(mtx) do { \
if ((mtx)->mtx_owner == curcpu()) \
panic("mutex %p held in %s\n", (mtx), __func__); \
} while (0)
struct mutex
{
volatile int mtx_lock;
int mtx_wantipl; /* interrupt priority level */
int mtx_oldipl;
void *mtx_owner;
};
/*****************
** sys/mutex.h **
*****************/
@ -298,6 +312,8 @@ void mtx_leave(struct mutex *);
#define INFSLP __UINT64_MAX__
#define KERNEL_ASSERT_LOCKED()
extern int nchrdev;
int enodev(void);
@ -315,6 +331,7 @@ void wakeup(const volatile void*);
int tsleep(const volatile void *, int, const char *, int);
int tsleep_nsec(const volatile void *, int, const char *, uint64_t);
int msleep(const volatile void *, struct mutex *, int, const char*, int);
int msleep_nsec(const volatile void *, struct mutex *, int, const char*, uint64_t);
int uiomove(void *, int, struct uio *);
@ -708,6 +725,13 @@ int timeout_del(struct timeout *);
#define htole32(x) ((uint32_t)(x))
/******************
** sys/stdint.h **
******************/
#define UINT64_MAX 0xffffffffffffffffULL
/****************
** sys/time.h **
****************/
@ -720,6 +744,24 @@ struct timeval
void microuptime(struct timeval *);
static inline uint64_t SEC_TO_NSEC(uint64_t seconds)
{
if (seconds > UINT64_MAX / 1000000000ULL)
return UINT64_MAX;
return seconds * 1000000000ULL;
}
/*************************
** arch specifc intr.h **
*************************/
#define IPL_SOFTNET 3
void *softintr_establish(int, void (*)(void *), void *);
void softintr_schedule(void *);
void softintr_disestablish(void *);
/***************************
** lib/libkern/libkern.h **

View File

@ -156,6 +156,7 @@ class Pci_driver
_pci.with_xml([&] (Xml_node node) {
node.for_each_sub_node("device", [&] (Xml_node node)
{
/* only use the first successfully probed device */
if (found) return;
String<16> name = node.attribute_value("name", String<16>());
@ -168,14 +169,9 @@ class Pci_driver
_sub_vendor_id = node.attribute_value("sub_vendor_id", 0U);
_sub_device_id = node.attribute_value("sub_device_id", 0U);
if ((_device_id == PCI_PRODUCT_INTEL_CORE4G_HDA_2) ||
(_vendor_id == PCI_VENDOR_INTEL && name == "00:03.0")) {
warning("ignore ", name,
", not supported HDMI/DP HDA device");
return;
}
if (_device.constructed())
_device.destruct();
/* we only construct the first useable device we find */
_device.construct(_pci, name);
_device->irq.sigh(_irq_handler);
@ -442,13 +438,6 @@ extern "C" int bus_dmamap_load(bus_dma_tag_t tag, bus_dmamap_t dmam, void *buf,
}
extern "C" void bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t)
{
Genode::warning("not implemented, called from ",
__builtin_return_address(0));
}
extern "C" int bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size, bus_size_t alignment,
bus_size_t boundary, bus_dma_segment_t *segs, int nsegs,
int *rsegs, int flags)
@ -497,15 +486,3 @@ extern "C" int bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs, int ns
return 0;
}
extern "C" void bus_dmamem_unmap(bus_dma_tag_t, caddr_t, size_t) { }
extern "C" paddr_t bus_dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *,
int, off_t, int, int)
{
Genode::warning("not implemented, called from ",
__builtin_return_address(0));
return 0;
}

View File

@ -220,6 +220,8 @@ class Bsd::Timer
bool const queued = _timeout->scheduled();
_timeout->discard();
_timeout.destruct();
return queued ? 1 : 0;
}
@ -306,6 +308,14 @@ extern "C" int msleep(const volatile void *ident, struct mutex *mtx,
}
extern "C" int
msleep_nsec(const volatile void *ident, struct mutex *mtx, int priority,
const char *wmesg, uint64_t nsecs)
{
return msleep(ident, mtx, priority, wmesg, nsecs / 1000000);
}
extern "C" void wakeup(const volatile void *ident)
{
Bsd::Task *sleep_task = _bsd_timer->sleep_task();