[2/2,saa7134] do not change mute state for capturing audio

Message ID 4E760BCA.6080900-patch2-2@list.ru (mailing list archive)
State Rejected, archived
Headers

Commit Message

Stas Sergeev Sept. 18, 2011, 3:18 p.m. UTC
  Hi Mauro, I've finally found the time (and an energy)
to go look into the automute breakage.
With the attached automute fix I no longer have
any problems with pulseaudio.
I also attached the patch that introduces an "std"
option to limit the scan list, resulting in a faster scan.
It is completely unrelated to the automute one, it is
here just in case.
What do you think?
  

Patch

>From 70709f12f7161c98cb7ebae104b520dc30c6bd53 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Sun, 18 Sep 2011 19:13:05 +0400
Subject: [PATCH 2/2] saa7134: introduce "std" module parameter to force video
 std

---
 drivers/media/video/saa7134/saa7134-video.c |   39 ++++++++++++++++++++++++--
 drivers/media/video/saa7134/saa7134.h       |    1 +
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 776ba2d..04ac7de 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -40,12 +40,15 @@  static unsigned int noninterlaced; /* 0 */
 static unsigned int gbufsize      = 720*576*4;
 static unsigned int gbufsize_max  = 720*576*4;
 static char secam[] = "--";
+static char std[16] = "--";
 module_param(video_debug, int, 0644);
 MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
 module_param(gbuffers, int, 0444);
 MODULE_PARM_DESC(gbuffers,"number of capture buffers, range 2-32");
 module_param(noninterlaced, int, 0644);
 MODULE_PARM_DESC(noninterlaced,"capture non interlaced video");
+module_param_string(std, std, sizeof(std), 0644);
+MODULE_PARM_DESC(secam, "force TV standard, either PAL, SECAM or NTSC");
 module_param_string(secam, secam, sizeof(secam), 0644);
 MODULE_PARM_DESC(secam, "force SECAM variant, either DK,L or Lc");
 
@@ -1847,14 +1850,20 @@  int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
 		return -EBUSY;
 	}
 
-	for (i = 0; i < TVNORMS; i++)
+	for (i = 0; i < TVNORMS; i++) {
+		if (!tvnorms[i].enabled)
+			continue;
 		if (*id == tvnorms[i].id)
 			break;
+	}
 
 	if (i == TVNORMS)
-		for (i = 0; i < TVNORMS; i++)
+		for (i = 0; i < TVNORMS; i++) {
+			if (!tvnorms[i].enabled)
+				continue;
 			if (*id & tvnorms[i].id)
 				break;
+		}
 	if (i == TVNORMS)
 		return -EINVAL;
 
@@ -1871,6 +1880,8 @@  int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
 				fixup = V4L2_STD_SECAM;
 		}
 		for (i = 0; i < TVNORMS; i++) {
+			if (!tvnorms[i].enabled)
+				continue;
 			if (fixup == tvnorms[i].id)
 				break;
 		}
@@ -2579,8 +2590,30 @@  int saa7134_videoport_init(struct saa7134_dev *dev)
 
 int saa7134_video_init2(struct saa7134_dev *dev)
 {
+	int i, idx = -1;
+	for (i = 0; i < TVNORMS; i++) {
+		int enable = (std[0] == '-' || strncasecmp(std,
+				tvnorms[i].name, strlen(std)) == 0);
+
+		if (secam[0] != '-') {
+			char buf[16] = "SECAM";
+			if (strncasecmp(buf, tvnorms[i].name,
+					strlen(buf)) == 0) {
+				strcat(buf, "-");
+				strcat(buf, secam);
+				if (strncasecmp(buf, tvnorms[i].name,
+						strlen(buf)) != 0)
+					enable = 0;
+			}
+		}
+		tvnorms[i].enabled = enable;
+		if (enable && idx == -1)
+			idx = i;
+	}
+	if (idx == -1)
+		return -EINVAL;
 	/* init video hw */
-	set_tvnorm(dev,&tvnorms[0]);
+	set_tvnorm(dev,&tvnorms[idx]);
 	video_mux(dev,0);
 	saa7134_tvaudio_setmute(dev);
 	saa7134_tvaudio_setvolume(dev,dev->ctl_volume);
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 28eb103..a0eddce 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -77,6 +77,7 @@  enum saa7134_video_out {
 struct saa7134_tvnorm {
 	char          *name;
 	v4l2_std_id   id;
+	int enabled;
 
 	/* video decoder */
 	unsigned int  sync_control;
-- 
1.7.6