Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jan 2020 18:52:42 +0000 (UTC)
From:      Chris Rees <crees@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r523348 - in head/audio/oss: . files
Message-ID:  <202001171852.00HIqgsP021744@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: crees
Date: Fri Jan 17 18:52:42 2020
New Revision: 523348
URL: https://svnweb.freebsd.org/changeset/ports/523348

Log:
  audio/oss: Fix build on recent FreeBSD
  
  Replace function calls to removed function timeout.
  
  Reviewed by:	jhb

Modified:
  head/audio/oss/Makefile
  head/audio/oss/files/patch-kernel_OS_FreeBSD_os__freebsd.c

Modified: head/audio/oss/Makefile
==============================================================================
--- head/audio/oss/Makefile	Fri Jan 17 18:27:27 2020	(r523347)
+++ head/audio/oss/Makefile	Fri Jan 17 18:52:42 2020	(r523348)
@@ -3,7 +3,7 @@
 
 PORTNAME=	oss
 DISTVERSION=	4.2-build2019
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	audio
 MASTER_SITES=	http://www.opensound.com/developer/sources/stable/bsd/
 DISTNAME=	${PORTNAME}-v${DISTVERSION}-src-bsd
@@ -22,12 +22,6 @@ LIB_DEPENDS=	libfontconfig.so:x11-fonts/fontconfig \
 USES=		gnome tar:bzip2 kmod pkgconfig
 USE_GNOME=	gtk20 cairo gdkpixbuf2
 USE_RC_SUBR=	oss
-
-.include <bsd.port.options.mk>
-
-.if ${OSVERSION} > 1300067
-BROKEN=	Still uses removed timeout interface and needs updating
-.endif
 
 HAS_CONFIGURE=	yes
 CONFIGURE_OUTSOURCE=	yes

Modified: head/audio/oss/files/patch-kernel_OS_FreeBSD_os__freebsd.c
==============================================================================
--- head/audio/oss/files/patch-kernel_OS_FreeBSD_os__freebsd.c	Fri Jan 17 18:27:27 2020	(r523347)
+++ head/audio/oss/files/patch-kernel_OS_FreeBSD_os__freebsd.c	Fri Jan 17 18:52:42 2020	(r523348)
@@ -1,36 +1,124 @@
---- kernel/OS/FreeBSD/os_freebsd.c.orig	2019-03-06 07:52:21 UTC
+--- kernel/OS/FreeBSD/os_freebsd.c.orig	2020-01-07 14:59:06 UTC
 +++ kernel/OS/FreeBSD/os_freebsd.c
-@@ -15,6 +15,9 @@
- #include "oss_config.h"
- #include "midi_core.h"
- #include <oss_pci.h>
-+#include <sys/param.h>
-+#include <sys/bus.h>
-+#include <sys/types.h>
- #include <sys/conf.h>
- #include <sys/module.h>
- #include <sys/proc.h>
-@@ -25,6 +28,7 @@
- #include <sys/poll.h>
- #include <sys/param.h>
- #include <sys/filio.h>
-+#include <sys/systm.h>
+@@ -473,7 +473,7 @@ typedef struct tmout_desc
+   void (*func) (void *);
+   void *arg;
  
- /* Function prototypes */
- static d_open_t oss_open;
-@@ -920,15 +924,9 @@ oss_poll (struct cdev *bsd_dev, int events, struct thr
-   return ev.revents;
+-  struct callout_handle timer;
++  struct callout timer;
+ } tmout_desc_t;
+ 
+ static volatile int next_id = 0;
+@@ -483,12 +483,17 @@ tmout_desc_t tmouts[MAX_TMOUTS] = { {0} };
+ 
+ int timeout_random = 0x12123400;
+ 
++static struct mtx oss_timeout_mutex;
++
+ void
+ oss_timer_callback (void *arg)
+ {
+   int ix;
++  void (*func) (void *);
+   tmout_desc_t *tmout = arg;
+ 
++  /* oss_timeout_mutex locked by callout */
++
+   timeout_random++;
+ 
+   if (!tmout->active)
+@@ -498,7 +503,10 @@ oss_timer_callback (void *arg)
+   tmout->active = 0;
+   tmout->timestamp = 0;
+ 
+-  tmout->func (arg);
++  func = tmout->func;
++  mtx_unlock(&oss_timeout_mutex);
++
++  func (arg);
  }
  
--#if defined(D_VERSION_03) && (D_VERSION == D_VERSION_03)
- static int
- oss_mmap (struct cdev *bsd_dev, vm_ooffset_t offset, vm_paddr_t * paddr,
- 	  int nprot, vm_memattr_t *memattr)
--#else
--static int
--oss_mmap (struct cdev *bsd_dev, vm_offset_t offset, vm_paddr_t * paddr,
--	  int nprot)
--#endif
+ timeout_id_t
+@@ -507,6 +515,8 @@ oss_timeout (void (*func) (void *), void *arg, unsigne
+   tmout_desc_t *tmout = NULL;
+   int id, n;
+ 
++  mtx_lock(&oss_timeout_mutex);
++
+   timeout_random++;
+ 
+   n = 0;
+@@ -527,6 +537,7 @@ oss_timeout (void (*func) (void *), void *arg, unsigne
+ 
+   if (id == -1)			/* No timer slots available */
+     {
++      mtx_unlock(&oss_timeout_mutex);
+       cmn_err (CE_CONT, "Timeout table full\n");
+       return 0;
+     }
+@@ -535,8 +546,10 @@ oss_timeout (void (*func) (void *), void *arg, unsigne
+   tmout->arg = arg;
+   tmout->timestamp = id | (timeout_random & ~0xff);
+ 
+-  tmout->timer = timeout (oss_timer_callback, tmout, ticks);
++  callout_reset(&tmout->timer, ticks, oss_timer_callback, tmout);
+ 
++  mtx_unlock(&oss_timeout_mutex);
++
+   return id | (timeout_random & ~0xff);
+ }
+ 
+@@ -550,15 +563,19 @@ oss_untimeout (timeout_id_t id)
+   if (ix < 0 || ix >= MAX_TMOUTS)
+     return;
+ 
++  mtx_lock(&oss_timeout_mutex);
++
+   timeout_random++;
+   tmout = &tmouts[ix];
+ 
+   if (tmout->timestamp != id)	/* Expired timer */
+     return;
+   if (tmout->active)
+-    untimeout (oss_timer_callback, tmout, tmout->timer);
++    callout_stop(&tmout->timer);
+   tmout->active = 0;
+   tmout->timestamp = 0;
++
++  mtx_unlock(&oss_timeout_mutex);
+ }
+ 
+ int
+@@ -618,6 +635,7 @@ oss_get_walltime (void)
+ int
+ soundcard_attach (void)
  {
-   int retval;
-   int dev;
++  int i;
+   oss_device_t *osdev;
+ 
+   if (module_lookupbyname("sound") != NULL)
+@@ -649,6 +667,12 @@ soundcard_attach (void)
+ 
+   oss_common_init (osdev);
+ 
++  mtx_init(&oss_timeout_mutex, "OSS timeout", NULL, MTX_DEF);
++
++  for (i = 0; i < MAX_TMOUTS; ++i)
++	callout_init_mtx(&tmouts[i].timer, &oss_timeout_mutex,
++			 CALLOUT_RETURNUNLOCKED);
++
+   return 0;
+ }
+ 
+@@ -659,6 +683,11 @@ soundcard_detach (void)
+ 
+   if (refcount > 0 || open_devices > 0)
+     return EBUSY;
++
++  for (i = 0; i < MAX_TMOUTS; ++i)
++	callout_drain(&tmouts[i].timer);
++
++  mtx_destroy(&oss_timeout_mutex);
+ 
+   oss_unload_drivers ();
+ 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001171852.00HIqgsP021744>