Linux Media Controller development
 help / color / mirror / Atom feed
From: Ext745 <stealth3m@yahoo.com>
To: linux-media@vger.kernel.org
Cc: isely@pobox.com, mkrufky@linuxtv.org, mchehab@kernel.org,
	hverkuil@kernel.org, Ext745 <stealth3m@yahoo.com>
Subject: [PATCH v2 1/4] media: cx25840: demodulate FM radio from a 5.5 MHz sound IF
Date: Thu, 22 Oct 2026 19:25:45 -0400	[thread overview]
Message-ID: <20261022232548.526232-2-stealth3m@yahoo.com> (raw)
In-Reply-To: <20261022232548.526232-1-stealth3m@yahoo.com>

Some boards feed FM radio to the cx2584x the same way as TV sound, as a
sound IF from the analog demodulator. On the Hauppauge HVR-1950 the
TDA8295 outputs FM radio as a 5.5 MHz SSIF on the cx25843's tuner audio
input. The radio setting cx25840 uses (0x808 = 0xf9, FM radio with
automatic detection) never locks onto that carrier with the standard
audio firmware: 0x805 keeps reading 0xff (no standard detected) and
only noise comes out.

Add a radio_sif_5_5mhz platform data flag. For such boards force the
5.5 MHz FM (A2-BG) standard, mono, in radio mode. That demodulates
broadcast FM cleanly, with 50 us de-emphasis (the hiss spectrum of an
empty channel follows the 50 us curve within 0.5 dB). The 4.5 MHz A2-M
standard would give 75 us but clips at broadcast FM deviation.

This path is mono only, so say so in g_tuner for radio: tuner-core
reports stereo capability for every radio.

Tested on an HVR-1950 (model 75111) with the pvrusb2 patch later in this
series: local stations across the band are clean, and switching between
radio, analog TV, composite and ATSC is unchanged.

Assisted-by: Claude Opus 5.5
Signed-off-by: Ext745 <stealth3m@yahoo.com>
---
v2: unchanged

 drivers/media/i2c/cx25840/cx25840-core.c | 23 +++++++++++++++++++++--
 drivers/media/i2c/cx25840/cx25840-core.h |  3 +++
 include/media/drv-intf/cx25840.h         |  6 +++++-
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index e90d71fe9..a7b4cae01 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1302,7 +1302,15 @@ static void input_change(struct i2c_client *client)
 
 	cx25840_and_or(client, 0x810, ~0x01, 1);
 
-	if (state->radio) {
+	if (state->radio && state->radio_sif_5_5mhz) {
+		/*
+		 * Forced 5.5 MHz FM (A2-BG standard), MONO1, which applies
+		 * 50 us de-emphasis.  The 4.5 MHz A2-M path (75 us) clips
+		 * broadcast FM deviation.
+		 */
+		cx25840_write(client, 0x808, 0x40);
+		cx25840_write(client, 0x80b, 0x00);
+	} else if (state->radio) {
 		cx25840_write(client, 0x808, 0xf9);
 		cx25840_write(client, 0x80b, 0x00);
 	} else if (std & V4L2_STD_525_60) {
@@ -2565,8 +2573,18 @@ static int cx25840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
 	u8 mode;
 	int val = 0;
 
-	if (state->radio)
+	if (state->radio) {
+		if (!state->radio_sif_5_5mhz)
+			return 0;
+		/*
+		 * The bridge calls this after the tuner, so that the audio
+		 * decoder has the last word: this FM path is mono only.
+		 */
+		vt->capability &= ~V4L2_TUNER_CAP_STEREO;
+		vt->rxsubchans = V4L2_TUNER_SUB_MONO;
+		vt->audmode = V4L2_TUNER_MODE_MONO;
 		return 0;
+	}
 
 	vt->signal = vpres ? 0xffff : 0x0;
 	if (is_cx2583x(state))
@@ -3972,6 +3990,7 @@ static int cx25840_probe(struct i2c_client *client)
 		struct cx25840_platform_data *pdata = client->dev.platform_data;
 
 		state->pvr150_workaround = pdata->pvr150_workaround;
+		state->radio_sif_5_5mhz = pdata->radio_sif_5_5mhz;
 	}
 
 	cx25840_ir_probe(sd);
diff --git a/drivers/media/i2c/cx25840/cx25840-core.h b/drivers/media/i2c/cx25840/cx25840-core.h
index 8b89e9068..94f17bd76 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.h
+++ b/drivers/media/i2c/cx25840/cx25840-core.h
@@ -43,6 +43,8 @@ enum cx25840_media_pads {
  * @mute:		audio mute V4L2 control (non-cx2583x devices only)
  * @pvr150_workaround:	whether we enable workaround for Hauppauge PVR150
  *			hardware bug (audio dropping out)
+ * @radio_sif_5_5mhz:	FM radio arrives as a 5.5 MHz sound IF (e.g. from a
+ *			TDA8295): demodulate it as 5.5 MHz FM mono
  * @generic_mode:	whether we disable ivtv-specific hacks
  *			this mode gets turned on when the bridge driver calls
  *			cx25840 subdevice init core op
@@ -78,6 +80,7 @@ struct cx25840_state {
 		struct v4l2_ctrl *mute;
 	};
 	int pvr150_workaround;
+	int radio_sif_5_5mhz;
 	bool generic_mode;
 	int radio;
 	v4l2_std_id std;
diff --git a/include/media/drv-intf/cx25840.h b/include/media/drv-intf/cx25840.h
index 8b455d9dd..c8ff9e65d 100644
--- a/include/media/drv-intf/cx25840.h
+++ b/include/media/drv-intf/cx25840.h
@@ -253,10 +253,14 @@ enum cx23885_io_pad {
  * is to select the audio standard explicitly. Many thanks to Hauppauge for
  * providing this information.
  *
- * This platform data only needs to be supplied by the ivtv driver.
+ * radio_sif_5_5mhz is for boards whose analog tuner delivers FM radio to the
+ * cx2584x as a 5.5 MHz sound IF, as the TDA8295 does in FM radio mode (e.g.
+ * the Hauppauge HVR-1950).  The audio firmware's FM radio mode does not find
+ * that carrier, so radio is demodulated as forced 5.5 MHz FM mono instead.
  */
 struct cx25840_platform_data {
 	int pvr150_workaround;
+	int radio_sif_5_5mhz;
 };
 
 #endif
-- 
2.53.0


  reply	other threads:[~2026-10-22 23:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261022232548.526232-1-stealth3m.ref@yahoo.com>
2026-10-22 23:25 ` [PATCH v2 0/4] media: FM radio for the Hauppauge WinTV-HVR-1950 Ext745
2026-10-22 23:25   ` Ext745 [this message]
2026-10-22 23:25   ` [PATCH v2 2/4] media: cx25840: FM stereo with an optional HVR-1950 audio firmware Ext745
2026-10-22 23:25   ` [PATCH v2 3/4] media: tda8290: report FM signal strength on the TDA8295 Ext745
2026-10-22 23:25   ` [PATCH v2 4/4] media: pvrusb2: enable FM radio on the HVR-1950 Ext745

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261022232548.526232-2-stealth3m@yahoo.com \
    --to=stealth3m@yahoo.com \
    --cc=hverkuil@kernel.org \
    --cc=isely@pobox.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mkrufky@linuxtv.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox