patch-2.2.19 linux/drivers/sbus/audio/dbri.c

Next file: linux/drivers/sbus/char/Makefile
Previous file: linux/drivers/sbus/audio/cs4215.h
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/drivers/sbus/audio/dbri.c linux/drivers/sbus/audio/dbri.c
@@ -1382,8 +1382,13 @@
 
         dbri->perchip_info.play.channels = 1;
         dbri->perchip_info.play.precision = 8;
-        dbri->perchip_info.play.gain = 128;
+        dbri->perchip_info.play.gain = (AUDIO_MAX_GAIN * 7 / 10);  /* 70% */
         dbri->perchip_info.play.balance = AUDIO_MID_BALANCE;
+        dbri->perchip_info.play.port = dbri->perchip_info.play.avail_ports =
+                AUDIO_SPEAKER | AUDIO_HEADPHONE | AUDIO_LINE_OUT;
+        dbri->perchip_info.record.port = AUDIO_MICROPHONE;
+        dbri->perchip_info.record.avail_ports =
+                AUDIO_MICROPHONE | AUDIO_LINE_IN;
 }
 
 /* mmcodec_setgain(dbri, int muted)
@@ -1406,6 +1411,7 @@
         } else {
                 int left_gain = (dbri->perchip_info.play.gain / 4) % 64;
                 int right_gain = (dbri->perchip_info.play.gain / 4) % 64;
+		int outport = dbri->perchip_info.play.port;
 
                 if (dbri->perchip_info.play.balance < AUDIO_MID_BALANCE) {
                         right_gain *= dbri->perchip_info.play.balance;
@@ -1416,8 +1422,12 @@
                         left_gain /= AUDIO_MID_BALANCE;
                 }
 
-                dbri->mm.data[0] = CS4215_LE | CS4215_HE | (63 - left_gain);
-                dbri->mm.data[1] = CS4215_SE | (63 - right_gain);
+		dbri->mm.data[0] = (63 - left_gain);
+		if (outport & AUDIO_HEADPHONE) dbri->mm.data[0] |= CS4215_HE;
+		if (outport & AUDIO_LINE_OUT)  dbri->mm.data[0] |= CS4215_LE;
+		dbri->mm.data[1] = (63 - right_gain);
+		if (outport & AUDIO_SPEAKER)   dbri->mm.data[1] |= CS4215_SE;
+
         }
 
         xmit_fixed(dbri, 20, *(int *)dbri->mm.data);
@@ -1585,7 +1595,7 @@
                 dbri->mm.offset = chi_offsets[i];
                 if (mmcodec_setctrl(dbri) && dbri->mm.version != 0xff) {
                         dbri->perchip_info.play.balance = AUDIO_MID_BALANCE;
-                        dbri->perchip_info.play.gain = AUDIO_MAX_GAIN/2;
+                        dbri->perchip_info.play.gain = AUDIO_MAX_GAIN*7/10;
                         return 0;
                 }
         }
@@ -1936,32 +1946,52 @@
 
 static int dbri_set_output_port(struct sparcaudio_driver *drv, int port)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	port &= dbri->perchip_info.play.avail_ports;
+	dbri->perchip_info.play.port = port;
+	mmcodec_setgain(dbri, 0);
+
+	return 0;
 }
 
 static int dbri_get_output_port(struct sparcaudio_driver *drv)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	return dbri->perchip_info.play.port;
 }
 
 static int dbri_set_input_port(struct sparcaudio_driver *drv, int port)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	port &= dbri->perchip_info.record.avail_ports;
+	dbri->perchip_info.record.port = port;
+	mmcodec_setgain(dbri, 0);
+
+	return 0;
 }
 
 static int dbri_get_input_port(struct sparcaudio_driver *drv)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	return dbri->perchip_info.record.port;
 }
 
 static int dbri_get_output_ports(struct sparcaudio_driver *drv)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	return dbri->perchip_info.play.avail_ports;
 }
 
 static int dbri_get_input_ports(struct sparcaudio_driver *drv)
 {
-        return 0;
+	struct dbri *dbri = (struct dbri *) drv->private;
+
+	return dbri->perchip_info.record.avail_ports;
 }
 
 /******************* sparcaudio midlevel - driver ID ********************/

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)