[PATCH] Cygwin: dsp: Fix a few trivial bugs.

2023-09-01 Thread Takashi Yano
Signed-off-by: Takashi Yano 
---
 winsup/cygwin/fhandler/dsp.cc   | 4 ++--
 winsup/cygwin/local_includes/fhandler.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler/dsp.cc b/winsup/cygwin/fhandler/dsp.cc
index 27f0a50ce..8e51a51c5 100644
--- a/winsup/cygwin/fhandler/dsp.cc
+++ b/winsup/cygwin/fhandler/dsp.cc
@@ -1060,7 +1060,7 @@ fhandler_dev_dsp::fixup_after_exec ()
 int
 fhandler_dev_dsp::open (int flags, mode_t)
 {
-  int ret = 0, err = 0;
+  int ret = -1, err = 0;
   UINT num_in = 0, num_out = 0;
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   // Work out initial sample format & frequency, /dev/dsp defaults
@@ -1095,7 +1095,7 @@ fhandler_dev_dsp::open (int flags, mode_t)
 
   debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d, ret=%d",
flags & O_ACCMODE, num_in, num_out, err, ret);
-  if (ret)
+  if (ret >= 0)
 being_closed = false;
   return ret;
 }
diff --git a/winsup/cygwin/local_includes/fhandler.h 
b/winsup/cygwin/local_includes/fhandler.h
index 9af5f716c..098b8dd19 100644
--- a/winsup/cygwin/local_includes/fhandler.h
+++ b/winsup/cygwin/local_includes/fhandler.h
@@ -2817,6 +2817,8 @@ class fhandler_dev_dsp: public fhandler_base
 
   void close_audio_in ();
   void close_audio_out (bool = false);
+
+ public:
   bool use_archetype () const {return true;}
 
   fhandler_dev_dsp (void *) {}
-- 
2.39.0



[PATCH] Cygwin: Implement sound mixer device.

2023-09-01 Thread Takashi Yano
This patch adds implementation of OSS-based sound mixer device. This
allows applications to change the sound playing volume.

NOTE: Currently, the recording volume cannot be changed.

Signed-off-by: Takashi Yano 
---
 winsup/cygwin/Makefile.am   |1 +
 winsup/cygwin/devices.cc| 1390 ---
 winsup/cygwin/devices.in|1 +
 winsup/cygwin/dtable.cc |3 +
 winsup/cygwin/fhandler/mixer.cc |  152 +++
 winsup/cygwin/local_includes/devices.h  |1 +
 winsup/cygwin/local_includes/fhandler.h |   29 +
 winsup/cygwin/release/3.5.0 |2 +
 8 files changed, 892 insertions(+), 687 deletions(-)
 create mode 100644 winsup/cygwin/fhandler/mixer.cc

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index bfb5ead10..9912b5399 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -89,6 +89,7 @@ FHANDLER_FILES= \
fhandler/dsp.cc \
fhandler/fifo.cc \
fhandler/floppy.cc \
+   fhandler/mixer.cc \
fhandler/mqueue.cc \
fhandler/netdrive.cc \
fhandler/nodevice.cc \
diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc
index 72c83d6e6..acdc54412 100644
--- a/winsup/cygwin/devices.cc
+++ b/winsup/cygwin/devices.cc
@@ -341,6 +341,7 @@ const _RDATA _device dev_storage[] =
   {"/dev/fd14", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 14)), "\\Device\\Floppy14", 
exists_ntdev, S_IFBLK, true},
   {"/dev/fd15", BRACK(FHDEV(DEV_FLOPPY_MAJOR, 15)), "\\Device\\Floppy15", 
exists_ntdev, S_IFBLK, true},
   {"/dev/full", BRACK(FH_FULL), "\\Device\\Null", exists_ntdev, S_IFCHR, true},
+  {"/dev/mixer", BRACK(FH_OSS_MIXER), "\\Device\\Null", exists_ntdev, S_IFCHR, 
true},
   {"/dev/nst0", BRACK(FHDEV(DEV_TAPE_MAJOR, 128)), "\\Device\\Tape0", 
exists_ntdev, S_IFCHR, true},
   {"/dev/nst1", BRACK(FHDEV(DEV_TAPE_MAJOR, 129)), "\\Device\\Tape1", 
exists_ntdev, S_IFCHR, true},
   {"/dev/nst2", BRACK(FHDEV(DEV_TAPE_MAJOR, 130)), "\\Device\\Tape2", 
exists_ntdev, S_IFCHR, true},
@@ -1029,9 +1030,9 @@ const _RDATA _device dev_storage[] =
 
 const _device *cons_dev = dev_storage + 20;
 const _device *console_dev = dev_storage + 148;
-const _device *ptym_dev = dev_storage + 724;
-const _device *ptys_dev = dev_storage + 298;
-const _device *urandom_dev = dev_storage + 719;
+const _device *ptym_dev = dev_storage + 725;
+const _device *ptys_dev = dev_storage + 299;
+const _device *urandom_dev = dev_storage + 720;
 
 
 static KR_device_t KR_find_keyword (const char *KR_keyword, int KR_length)
@@ -1061,7 +1062,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":pipe", 5) == 0)
 {
 {
-return dev_storage + 723;
+return dev_storage + 724;
 
 }
 }
@@ -1076,7 +1077,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":fifo", 5) == 0)
 {
 {
-return dev_storage + 722;
+return dev_storage + 723;
 
 }
 }
@@ -1100,7 +1101,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym9", 6) == 0)
 {
 {
-return dev_storage + 733;
+return dev_storage + 734;
 
 }
 }
@@ -1115,7 +1116,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym8", 6) == 0)
 {
 {
-return dev_storage + 732;
+return dev_storage + 733;
 
 }
 }
@@ -1130,7 +1131,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym7", 6) == 0)
 {
 {
-return dev_storage + 731;
+return dev_storage + 732;
 
 }
 }
@@ -1145,7 +1146,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym6", 6) == 0)
 {
 {
-return dev_storage + 730;
+return dev_storage + 731;
 
 }
 }
@@ -1160,7 +1161,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym5", 6) == 0)
 {
 {
-return dev_storage + 729;
+return dev_storage + 730;
 
 }
 }
@@ -1175,7 +1176,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym4", 6) == 0)
 {
 {
-return dev_storage + 728;
+return dev_storage + 729;
 
 }
 }
@@ -1190,7 +1191,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym3", 6) == 0)
 {
 {
-return dev_storage + 727;
+return dev_storage + 728;
 
 }
 }
@@ -1205,7 +1206,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym2", 6) == 0)
 {
 {
-return dev_storage + 726;
+return dev_storage + 727;
 
 }
 }
@@ -1220,7 +1221,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym1", 6) == 0)
 {
 {
-return dev_storage + 725;
+return dev_storage + 726;
 
 }
 }
@@ -1235,7 +1236,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym0", 6) == 0)
 {
 {
-return dev_storage + 724;
+return dev_storage + 725;
 
 }
 }
@@ -1277,7 +1278,7 @@ returnNULL;
   if (strncmp (KR_keyword, ":ptym99", 7) == 0)
 {
 {
-return dev_storage + 823;
+return dev_storage + 824;
 
 }
 }
@@ -1292,7 

Re: [PATCH] Cygwin: Implement sound mixer device.

2023-09-01 Thread Corinna Vinschen
On Sep  1 19:04, Takashi Yano wrote:
> This patch adds implementation of OSS-based sound mixer device. This
> allows applications to change the sound playing volume.

Cool!  Go ahead, that's a nice addition.

> NOTE: Currently, the recording volume cannot be changed.

I guess you're already hacking on adding that :)


Thanks,
Corinna


[PATCH v2] Cygwin: cpuinfo: Linux 6.5 additions

2023-09-01 Thread Brian Inglis
add AMD 0x801f EAX 14 debug_swap SEV-ES full debug state swap

Signed-off-by: Brian Inglis 
---
 winsup/cygwin/fhandler/proc.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
index cbc49a12a417..be107cb8eacc 100644
--- a/winsup/cygwin/fhandler/proc.cc
+++ b/winsup/cygwin/fhandler/proc.cc
@@ -1652,7 +1652,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
 /*   ftcprint (features2, 11, "sev_64b");*//* SEV 64 bit host guest only */
 /*   ftcprint (features2, 12, "sev_rest_inj");   *//* SEV restricted 
injection */
 /*   ftcprint (features2, 13, "sev_alt_inj");*//* SEV alternate 
injection */
-/*   ftcprint (features2, 14, "sev_es_dbg_swap");*//* SEV-ES debug state 
swap */
+ ftcprint (features2, 14, "debug_swap");   /* SEV-ES full debug state 
swap */
 /*   ftcprint (features2, 15, "no_host_ibs");*//* host IBS unsupported 
*/
 /*   ftcprint (features2, 16, "vte");*//* virtual transparent 
encryption */
}
-- 
2.39.0



Re: [PATCH v2] Cygwin: cpuinfo: Linux 6.5 additions

2023-09-01 Thread Corinna Vinschen
On Sep  1 11:42, Brian Inglis wrote:
> add AMD 0x801f EAX 14 debug_swap SEV-ES full debug state swap
> 
> Signed-off-by: Brian Inglis 
> ---
>  winsup/cygwin/fhandler/proc.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/fhandler/proc.cc b/winsup/cygwin/fhandler/proc.cc
> index cbc49a12a417..be107cb8eacc 100644
> --- a/winsup/cygwin/fhandler/proc.cc
> +++ b/winsup/cygwin/fhandler/proc.cc
> @@ -1652,7 +1652,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
>  /* ftcprint (features2, 11, "sev_64b");*//* SEV 64 bit host guest only */
>  /* ftcprint (features2, 12, "sev_rest_inj");   *//* SEV restricted 
> injection */
>  /* ftcprint (features2, 13, "sev_alt_inj");*//* SEV alternate 
> injection */
> -/* ftcprint (features2, 14, "sev_es_dbg_swap");*//* SEV-ES debug state 
> swap */
> +   ftcprint (features2, 14, "debug_swap");   /* SEV-ES full debug state 
> swap */
>  /* ftcprint (features2, 15, "no_host_ibs");*//* host IBS unsupported 
> */
>  /* ftcprint (features2, 16, "vte");*//* virtual transparent 
> encryption */
>   }
> -- 
> 2.39.0

Pushed.

Thanks,
Corinna