On Thu, Oct 27, 2022 at 08:35:31PM +0000, Klemens Nanni wrote:
> On Thu, Oct 27, 2022 at 03:51:05PM +0200, Alexandre Ratchov wrote:
> > On Thu, Oct 27, 2022 at 01:08:57PM +0000, Klemens Nanni wrote:
> > > @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags)
> > >  
> > >   DPRINTF(("ad1848_open: sc=%p\n", sc));
> > >  
> > > + if ((flags & (FWRITE | FREAD)) && sc->mode != 2)
> > > +         return ENXIO;
> > > +
> > >   sc->sc_pintr = sc->sc_parg = NULL;
> > >   sc->sc_rintr = sc->sc_rarg = NULL;
> > >  
> > 
> > afaiu, the correct condition for full-duplex check is:
> > 
> >     if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD))
> >             ...
> > 
> > (both FWRITE and FREAD set)
> 
> Here's the correct version, sorry for the noise.

no problem! ok ratchov

> ---
>  sys/dev/isa/ad1848.c    | 12 ++++--------
>  sys/dev/isa/ad1848var.h |  2 --
>  sys/dev/isa/ess.c       | 29 ++++++++++++-----------------
>  sys/dev/isa/gus.c       | 20 ++++----------------
>  sys/dev/isa/gusvar.h    |  2 --
>  sys/dev/isa/pas.c       |  1 -
>  sys/dev/isa/sb.c        |  1 -
>  sys/dev/isa/sbdsp.c     | 11 ++++-------
>  sys/dev/isa/sbdspvar.h  |  2 --
>  9 files changed, 24 insertions(+), 56 deletions(-)
> 
> diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c
> index bb2b95277a1..26b2cc2ba88 100644
> --- a/sys/dev/isa/ad1848.c
> +++ b/sys/dev/isa/ad1848.c
> @@ -74,6 +74,7 @@
>  #include <sys/syslog.h>
>  #include <sys/device.h>
>  #include <sys/buf.h>
> +#include <sys/fcntl.h>
>  
>  #include <machine/cpu.h>
>  #include <machine/bus.h>
> @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags)
>  
>       DPRINTF(("ad1848_open: sc=%p\n", sc));
>  
> +     if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) && sc->mode != 2)
> +             return ENXIO;
> +
>       sc->sc_pintr = sc->sc_parg = NULL;
>       sc->sc_rintr = sc->sc_rarg = NULL;
>  
> @@ -1458,11 +1462,3 @@ ad1848_round(void *addr, int direction, size_t size)
>               size = MAX_ISADMA;
>       return size;
>  }
> -
> -int
> -ad1848_get_props(void *addr)
> -{
> -     struct ad1848_softc *sc = addr;
> -
> -     return (sc->mode == 2 ? AUDIO_PROP_FULLDUPLEX : 0);
> -}
> diff --git a/sys/dev/isa/ad1848var.h b/sys/dev/isa/ad1848var.h
> index 49c199f64fc..c8af3f04b4b 100644
> --- a/sys/dev/isa/ad1848var.h
> +++ b/sys/dev/isa/ad1848var.h
> @@ -210,6 +210,4 @@ void   *ad1848_malloc(void *, int, size_t, int, int);
>  void ad1848_free(void *, void *, int);
>  size_t       ad1848_round(void *, int, size_t);
>  
> -int  ad1848_get_props(void *);
> -
>  #endif
> diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c
> index 8989dd94b01..eba480013cf 100644
> --- a/sys/dev/isa/ess.c
> +++ b/sys/dev/isa/ess.c
> @@ -74,6 +74,7 @@
>  #include <sys/device.h>
>  #include <sys/kernel.h>
>  #include <sys/timeout.h>
> +#include <sys/fcntl.h>
>  
>  #include <machine/cpu.h>
>  #include <machine/intr.h>
> @@ -115,6 +116,7 @@ struct audio_params ess_audio_default =
>  
>  int  ess_setup_sc(struct ess_softc *, int);
>  
> +int  ess_1788_open(void *, int);
>  int  ess_open(void *, int);
>  void ess_1788_close(void *);
>  void ess_1888_close(void *);
> @@ -148,8 +150,6 @@ size_t    ess_round_buffersize(void *, int, size_t);
>  
>  
>  int  ess_query_devinfo(void *, mixer_devinfo_t *);
> -int  ess_1788_get_props(void *);
> -int  ess_1888_get_props(void *);
>  
>  void ess_speaker_on(struct ess_softc *);
>  void ess_speaker_off(struct ess_softc *);
> @@ -198,7 +198,7 @@ static const char *essmodel[] = {
>   */
>  
>  const struct audio_hw_if ess_1788_hw_if = {
> -     .open = ess_open,
> +     .open = ess_1788_open,
>       .close = ess_1788_close,
>       .set_params = ess_set_params,
>       .round_blocksize = ess_round_blocksize,
> @@ -211,7 +211,6 @@ const struct audio_hw_if ess_1788_hw_if = {
>       .allocm = ess_malloc,
>       .freem = ess_free,
>       .round_buffersize = ess_round_buffersize,
> -     .get_props = ess_1788_get_props,
>       .trigger_output = ess_audio1_trigger_output,
>       .trigger_input = ess_audio1_trigger_input,
>  };
> @@ -230,7 +229,6 @@ const struct audio_hw_if ess_1888_hw_if = {
>       .allocm = ess_malloc,
>       .freem = ess_free,
>       .round_buffersize = ess_round_buffersize,
> -     .get_props = ess_1888_get_props,
>       .trigger_output = ess_audio2_trigger_output,
>       .trigger_input = ess_audio1_trigger_input,
>  };
> @@ -982,6 +980,15 @@ essattach(struct ess_softc *sc)
>   * Various routines to interface to higher level audio driver
>   */
>  
> +int
> +ess_1788_open(void *addr, int flags)
> +{
> +     if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD))
> +             return ENXIO;
> +
> +     return ess_open(addr, flags);
> +}
> +
>  int
>  ess_open(void *addr, int flags)
>  {
> @@ -2059,18 +2066,6 @@ ess_round_buffersize(void *addr, int direction, size_t 
> size)
>       return (size);
>  }
>  
> -int
> -ess_1788_get_props(void *addr)
> -{
> -     return (0);
> -}
> -
> -int
> -ess_1888_get_props(void *addr)
> -{
> -     return (AUDIO_PROP_FULLDUPLEX);
> -}
> -
>  /* ============================================
>   * Generic functions for ess, not used by audio h/w i/f
>   * =============================================
> diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c
> index 45fe009fc61..6e1d1a00cef 100644
> --- a/sys/dev/isa/gus.c
> +++ b/sys/dev/isa/gus.c
> @@ -277,7 +277,6 @@ const struct audio_hw_if gus_hw_if = {
>       .allocm = gus_malloc,
>       .freem = gus_free,
>       .round_buffersize = gus_round,
> -     .get_props = gus_get_props,
>  };
>  
>  static const struct audio_hw_if gusmax_hw_if = {
> @@ -297,7 +296,6 @@ static const struct audio_hw_if gusmax_hw_if = {
>       .allocm = ad1848_malloc,
>       .freem = ad1848_free,
>       .round_buffersize = ad1848_round,
> -     .get_props = gusmax_get_props,
>  };
>  
>  int
> @@ -307,6 +305,10 @@ gusopen(void *addr, int flags)
>  
>       DPRINTF(("gusopen() called\n"));
>  
> +     if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) &&
> +         sc->sc_recdrq == sc->sc_drq)
> +             return ENXIO;
> +
>       if (sc->sc_flags & GUS_OPEN)
>               return EBUSY;
>  
> @@ -2671,20 +2673,6 @@ gus_mixer_set_port(void *addr, mixer_ctrl_t *cp)
>       return error;
>  }
>  
> -int
> -gus_get_props(void *addr)
> -{
> -     struct gus_softc *sc = addr;
> -     return (sc->sc_recdrq == sc->sc_drq ? 0 : AUDIO_PROP_FULLDUPLEX);
> -}
> -
> -int
> -gusmax_get_props(void *addr)
> -{
> -     struct ad1848_softc *ac = addr;
> -     return gus_get_props(ac->parent);
> -}
> -
>  int
>  gusmax_mixer_query_devinfo(void *addr, mixer_devinfo_t *dip)
>  {
> diff --git a/sys/dev/isa/gusvar.h b/sys/dev/isa/gusvar.h
> index e979f53c6ac..6ce0b851ca2 100644
> --- a/sys/dev/isa/gusvar.h
> +++ b/sys/dev/isa/gusvar.h
> @@ -371,8 +371,6 @@ int       gusmax_mixer_query_devinfo(void *, 
> mixer_devinfo_t *);
>  void   *gus_malloc(void *, int, size_t, int, int);
>  void gus_free(void *, void *, int);
>  size_t       gus_round(void *, int, size_t);
> -int  gus_get_props(void *);
> -int  gusmax_get_props(void *);
>  
>  void gusics_master_mute(struct ics2101_softc *, int);
>  void gusics_dac_mute(struct ics2101_softc *, int);
> diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c
> index 2204b1be495..42c2183d12d 100644
> --- a/sys/dev/isa/pas.c
> +++ b/sys/dev/isa/pas.c
> @@ -122,7 +122,6 @@ const struct audio_hw_if pas_hw_if = {
>       .allocm = sb_malloc,
>       .freem = sb_free,
>       .round_buffersize = sb_round,
> -     .get_props = sbdsp_get_props,
>       .trigger_output = sbdsp_trigger_output,
>       .trigger_input = sbdsp_trigger_input,
>  };
> diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c
> index bf2bb45c5fa..4c0b17c0214 100644
> --- a/sys/dev/isa/sb.c
> +++ b/sys/dev/isa/sb.c
> @@ -107,7 +107,6 @@ const struct audio_hw_if sb_hw_if = {
>       .allocm = sb_malloc,
>       .freem = sb_free,
>       .round_buffersize = sb_round,
> -     .get_props = sbdsp_get_props,
>       .trigger_output = sbdsp_trigger_output,
>       .trigger_input = sbdsp_trigger_input,
>  };
> diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c
> index 4ca26c110ef..c2996b3f03f 100644
> --- a/sys/dev/isa/sbdsp.c
> +++ b/sys/dev/isa/sbdsp.c
> @@ -53,6 +53,7 @@
>  #include <sys/syslog.h>
>  #include <sys/device.h>
>  #include <sys/buf.h>
> +#include <sys/fcntl.h>
>  
>  #include <machine/cpu.h>
>  #include <machine/intr.h>
> @@ -2112,13 +2113,6 @@ sb_round(void *addr, int direction, size_t size)
>       return size;
>  }
>  
> -int
> -sbdsp_get_props(void *addr)
> -{
> -     struct sbdsp_softc *sc = addr;
> -     return (sc->sc_fullduplex ? AUDIO_PROP_FULLDUPLEX : 0);
> -}
> -
>  #if NMIDI > 0
>  /*
>   * MIDI related routines.
> @@ -2132,6 +2126,9 @@ sbdsp_midi_open(void *addr, int flags, void 
> (*iintr)(void *, int),
>  
>          DPRINTF(("sbdsp_midi_open: sc=%p\n", sc));
>  
> +     if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) &&
> +         !sc->sc_fullduplex)
> +             return ENXIO;
>       if (sc->sc_open != SB_CLOSED)
>               return EBUSY;
>       if (sbdsp_reset(sc) != 0)
> diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h
> index 188cdf205b2..f862799d102 100644
> --- a/sys/dev/isa/sbdspvar.h
> +++ b/sys/dev/isa/sbdspvar.h
> @@ -243,8 +243,6 @@ void      *sb_malloc(void *, int, size_t, int, int);
>  void sb_free(void *, void *, int);
>  size_t sb_round(void *, int, size_t);
>  
> -int  sbdsp_get_props(void *);
> -
>  
>  int  sbdsp_midi_open(void *, int,
>                            void (*iintr)(void *, int),
> -- 
> 2.38.1
> 
> 

Reply via email to