* [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards
@ 2017-06-21 4:33 Hervé Poussineau
2017-06-21 4:34 ` [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments Hervé Poussineau
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Hervé Poussineau @ 2017-06-21 4:33 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Hervé Poussineau
Hi,
This patchset removes a global variable in adlib emulation, and allows to
have multiple adlib sound cards.
Note that indentation seem off because I have replaced some tabulations by spaces.
Before:
qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
qemu-system-i386: -device adlib,iobase=0x240: Cannot create more than 1 adlib device
After:
qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
Machine starts.
Hervé
Hervé Poussineau (2):
audio/fmopl: modify timer callback to give opaque and channel
parameters in two arguments
audio/adlib: remove limitation of one adlib card
hw/audio/adlib.c | 14 +++-----------
hw/audio/fmopl.c | 18 +++++++++++++-----
hw/audio/fmopl.h | 7 ++++---
3 files changed, 20 insertions(+), 19 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments
2017-06-21 4:33 [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
@ 2017-06-21 4:34 ` Hervé Poussineau
2017-07-13 10:18 ` Philippe Mathieu-Daudé
2017-06-21 4:34 ` [Qemu-devel] [PATCH 2/2] audio/adlib: remove limitation of one adlib card Hervé Poussineau
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Hervé Poussineau @ 2017-06-21 4:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Hervé Poussineau
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/audio/adlib.c | 2 +-
hw/audio/fmopl.c | 18 +++++++++++++-----
hw/audio/fmopl.h | 7 ++++---
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
index c6e0f10c16..be4203476a 100644
--- a/hw/audio/adlib.c
+++ b/hw/audio/adlib.c
@@ -130,7 +130,7 @@ static uint32_t adlib_read(void *opaque, uint32_t nport)
return data;
}
-static void timer_handler (int c, double interval_Sec)
+static void timer_handler (void *opaque, int c, double interval_Sec)
{
AdlibState *s = glob_adlib;
unsigned n = c & 1;
diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
index 202f752c5d..5cfb6a96dd 100644
--- a/hw/audio/fmopl.c
+++ b/hw/audio/fmopl.c
@@ -788,14 +788,18 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
{
double interval = st2 ? (double)OPL->T[1]*OPL->TimerBase : 0.0;
OPL->st[1] = st2;
- if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+1,interval);
+ if (OPL->TimerHandler) {
+ (OPL->TimerHandler)(OPL->TimerParam, 1, interval);
+ }
}
/* timer 1 */
if(OPL->st[0] != st1)
{
double interval = st1 ? (double)OPL->T[0]*OPL->TimerBase : 0.0;
OPL->st[0] = st1;
- if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+0,interval);
+ if (OPL->TimerHandler) {
+ (OPL->TimerHandler)(OPL->TimerParam, 0, interval);
+ }
}
}
return;
@@ -1128,10 +1132,11 @@ void OPLDestroy(FM_OPL *OPL)
/* ---------- Option handlers ---------- */
-void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset)
+void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
+ void *param)
{
OPL->TimerHandler = TimerHandler;
- OPL->TimerParam = channelOffset;
+ OPL->TimerParam = param;
}
/* ---------- YM3812 I/O interface ---------- */
@@ -1197,6 +1202,9 @@ int OPLTimerOver(FM_OPL *OPL,int c)
}
}
/* reload timer */
- if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+c,(double)OPL->T[c]*OPL->TimerBase);
+ if (OPL->TimerHandler) {
+ (OPL->TimerHandler)(OPL->TimerParam, c,
+ (double)OPL->T[c] * OPL->TimerBase);
+ }
return OPL->status>>7;
}
diff --git a/hw/audio/fmopl.h b/hw/audio/fmopl.h
index fc9f16b58a..f4065f425c 100644
--- a/hw/audio/fmopl.h
+++ b/hw/audio/fmopl.h
@@ -3,7 +3,7 @@
#include <stdint.h>
-typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
+typedef void (*OPL_TIMERHANDLER)(void *param, int channel, double interval_Sec);
/* !!!!! here is private section , do not access there member direct !!!!! */
@@ -87,13 +87,14 @@ typedef struct fm_opl_f {
uint8_t wavesel;
/* external event callback handler */
OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
- int TimerParam; /* TIMER parameter */
+ void *TimerParam; /* TIMER parameter */
} FM_OPL;
/* ---------- Generic interface section ---------- */
FM_OPL *OPLCreate(int clock, int rate);
void OPLDestroy(FM_OPL *OPL);
-void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
+void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
+ void *param);
int OPLWrite(FM_OPL *OPL,int a,int v);
unsigned char OPLRead(FM_OPL *OPL,int a);
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] audio/adlib: remove limitation of one adlib card
2017-06-21 4:33 [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
2017-06-21 4:34 ` [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments Hervé Poussineau
@ 2017-06-21 4:34 ` Hervé Poussineau
2017-07-13 5:51 ` [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
2017-07-13 10:19 ` Philippe Mathieu-Daudé
3 siblings, 0 replies; 6+ messages in thread
From: Hervé Poussineau @ 2017-06-21 4:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Hervé Poussineau
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
hw/audio/adlib.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
index be4203476a..6a5d39a8c8 100644
--- a/hw/audio/adlib.c
+++ b/hw/audio/adlib.c
@@ -74,8 +74,6 @@ typedef struct {
PortioList port_list;
} AdlibState;
-static AdlibState *glob_adlib;
-
static void adlib_stop_opl_timer (AdlibState *s, size_t n)
{
OPLTimerOver (s->opl, n);
@@ -132,7 +130,7 @@ static uint32_t adlib_read(void *opaque, uint32_t nport)
static void timer_handler (void *opaque, int c, double interval_Sec)
{
- AdlibState *s = glob_adlib;
+ AdlibState *s = opaque;
unsigned n = c & 1;
#ifdef DEBUG
double interval;
@@ -259,19 +257,13 @@ static void adlib_realizefn (DeviceState *dev, Error **errp)
AdlibState *s = ADLIB(dev);
struct audsettings as;
- if (glob_adlib) {
- error_setg (errp, "Cannot create more than 1 adlib device");
- return;
- }
- glob_adlib = s;
-
s->opl = OPLCreate (3579545, s->freq);
if (!s->opl) {
error_setg (errp, "OPLCreate %d failed", s->freq);
return;
}
else {
- OPLSetTimerHandler (s->opl, timer_handler, 0);
+ OPLSetTimerHandler(s->opl, timer_handler, s);
s->enabled = 1;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards
2017-06-21 4:33 [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
2017-06-21 4:34 ` [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments Hervé Poussineau
2017-06-21 4:34 ` [Qemu-devel] [PATCH 2/2] audio/adlib: remove limitation of one adlib card Hervé Poussineau
@ 2017-07-13 5:51 ` Hervé Poussineau
2017-07-13 10:19 ` Philippe Mathieu-Daudé
3 siblings, 0 replies; 6+ messages in thread
From: Hervé Poussineau @ 2017-07-13 5:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Ping ?
Le 21/06/2017 à 06:33, Hervé Poussineau a écrit :
> Hi,
>
> This patchset removes a global variable in adlib emulation, and allows to
> have multiple adlib sound cards.
> Note that indentation seem off because I have replaced some tabulations by spaces.
>
> Before:
> qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
> qemu-system-i386: -device adlib,iobase=0x240: Cannot create more than 1 adlib device
>
> After:
> qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
> Machine starts.
>
> Hervé
>
> Hervé Poussineau (2):
> audio/fmopl: modify timer callback to give opaque and channel
> parameters in two arguments
> audio/adlib: remove limitation of one adlib card
>
> hw/audio/adlib.c | 14 +++-----------
> hw/audio/fmopl.c | 18 +++++++++++++-----
> hw/audio/fmopl.h | 7 ++++---
> 3 files changed, 20 insertions(+), 19 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments
2017-06-21 4:34 ` [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments Hervé Poussineau
@ 2017-07-13 10:18 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-13 10:18 UTC (permalink / raw)
To: Hervé Poussineau, qemu-devel; +Cc: Gerd Hoffmann
Hi Hervé,
On 06/21/2017 01:34 AM, Hervé Poussineau wrote:
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> ---
> hw/audio/adlib.c | 2 +-
> hw/audio/fmopl.c | 18 +++++++++++++-----
> hw/audio/fmopl.h | 7 ++++---
> 3 files changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c
> index c6e0f10c16..be4203476a 100644
> --- a/hw/audio/adlib.c
> +++ b/hw/audio/adlib.c
> @@ -130,7 +130,7 @@ static uint32_t adlib_read(void *opaque, uint32_t nport)
> return data;
> }
>
> -static void timer_handler (int c, double interval_Sec)
> +static void timer_handler (void *opaque, int c, double interval_Sec)
> {
> AdlibState *s = glob_adlib;
> unsigned n = c & 1;
> diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
> index 202f752c5d..5cfb6a96dd 100644
> --- a/hw/audio/fmopl.c
> +++ b/hw/audio/fmopl.c
> @@ -788,14 +788,18 @@ static void OPLWriteReg(FM_OPL *OPL, int r, int v)
> {
> double interval = st2 ? (double)OPL->T[1]*OPL->TimerBase : 0.0;
> OPL->st[1] = st2;
> - if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+1,interval);
> + if (OPL->TimerHandler) {
> + (OPL->TimerHandler)(OPL->TimerParam, 1, interval);
> + }
> }
> /* timer 1 */
> if(OPL->st[0] != st1)
> {
> double interval = st1 ? (double)OPL->T[0]*OPL->TimerBase : 0.0;
> OPL->st[0] = st1;
> - if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+0,interval);
> + if (OPL->TimerHandler) {
> + (OPL->TimerHandler)(OPL->TimerParam, 0, interval);
> + }
> }
> }
> return;
> @@ -1128,10 +1132,11 @@ void OPLDestroy(FM_OPL *OPL)
>
> /* ---------- Option handlers ---------- */
>
> -void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset)
> +void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
> + void *param)
> {
> OPL->TimerHandler = TimerHandler;
> - OPL->TimerParam = channelOffset;
> + OPL->TimerParam = param;
> }
>
> /* ---------- YM3812 I/O interface ---------- */
> @@ -1197,6 +1202,9 @@ int OPLTimerOver(FM_OPL *OPL,int c)
> }
> }
> /* reload timer */
> - if (OPL->TimerHandler) (OPL->TimerHandler)(OPL->TimerParam+c,(double)OPL->T[c]*OPL->TimerBase);
> + if (OPL->TimerHandler) {
> + (OPL->TimerHandler)(OPL->TimerParam, c,
> + (double)OPL->T[c] * OPL->TimerBase);
> + }
> return OPL->status>>7;
> }
> diff --git a/hw/audio/fmopl.h b/hw/audio/fmopl.h
> index fc9f16b58a..f4065f425c 100644
> --- a/hw/audio/fmopl.h
> +++ b/hw/audio/fmopl.h
> @@ -3,7 +3,7 @@
>
> #include <stdint.h>
>
> -typedef void (*OPL_TIMERHANDLER)(int channel,double interval_Sec);
> +typedef void (*OPL_TIMERHANDLER)(void *param, int channel, double interval_Sec);
>
> /* !!!!! here is private section , do not access there member direct !!!!! */
>
> @@ -87,13 +87,14 @@ typedef struct fm_opl_f {
> uint8_t wavesel;
> /* external event callback handler */
> OPL_TIMERHANDLER TimerHandler; /* TIMER handler */
> - int TimerParam; /* TIMER parameter */
> + void *TimerParam; /* TIMER parameter */
not very useful comment ;)
> } FM_OPL;
>
> /* ---------- Generic interface section ---------- */
> FM_OPL *OPLCreate(int clock, int rate);
> void OPLDestroy(FM_OPL *OPL);
> -void OPLSetTimerHandler(FM_OPL *OPL,OPL_TIMERHANDLER TimerHandler,int channelOffset);
> +void OPLSetTimerHandler(FM_OPL *OPL, OPL_TIMERHANDLER TimerHandler,
> + void *param);
>
> int OPLWrite(FM_OPL *OPL,int a,int v);
> unsigned char OPLRead(FM_OPL *OPL,int a);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards
2017-06-21 4:33 [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
` (2 preceding siblings ...)
2017-07-13 5:51 ` [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
@ 2017-07-13 10:19 ` Philippe Mathieu-Daudé
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-13 10:19 UTC (permalink / raw)
To: Hervé Poussineau, qemu-devel; +Cc: Gerd Hoffmann
On 06/21/2017 01:33 AM, Hervé Poussineau wrote:
> Hi,
>
> This patchset removes a global variable in adlib emulation, and allows to
> have multiple adlib sound cards.
> Note that indentation seem off because I have replaced some tabulations by spaces.
>
> Before:
> qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
> qemu-system-i386: -device adlib,iobase=0x240: Cannot create more than 1 adlib device
>
> After:
> qemu-system-i386 -device adlib,iobase=0x220 -device adlib,iobase=0x240
> Machine starts.
>
> Hervé
>
> Hervé Poussineau (2):
> audio/fmopl: modify timer callback to give opaque and channel
> parameters in two arguments
> audio/adlib: remove limitation of one adlib card
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> hw/audio/adlib.c | 14 +++-----------
> hw/audio/fmopl.c | 18 +++++++++++++-----
> hw/audio/fmopl.h | 7 ++++---
> 3 files changed, 20 insertions(+), 19 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-07-13 10:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 4:33 [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
2017-06-21 4:34 ` [Qemu-devel] [PATCH 1/2] audio/fmopl: modify timer callback to give opaque and channel parameters in two arguments Hervé Poussineau
2017-07-13 10:18 ` Philippe Mathieu-Daudé
2017-06-21 4:34 ` [Qemu-devel] [PATCH 2/2] audio/adlib: remove limitation of one adlib card Hervé Poussineau
2017-07-13 5:51 ` [Qemu-devel] [PATCH 0/2] Support multiple adlib sound cards Hervé Poussineau
2017-07-13 10:19 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.