public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: linux-media@vger.kernel.org
Cc: Oliver Endriss <o.endriss@gmx.de>, Ralph Metzler <rjkm@metzlerbros.de>
Subject: Re: [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge)
Date: Fri, 15 Jul 2011 00:56:31 -0300	[thread overview]
Message-ID: <4E1FBA6F.10509@redhat.com> (raw)
In-Reply-To: <4E1F8E1F.3000008@redhat.com>

Em 14-07-2011 21:47, Mauro Carvalho Chehab escreveu:
> Em 14-07-2011 20:45, Oliver Endriss escreveu:
>> - DVB-T tuning does not work anymore.
> I think that the better is to revert my patch and apply a solution similar
> to cxd2820r_attach. It should work fine if called just once (like ngene/ddbridge)
> or twice (like em28xx).

I ended by fixing it at the easiest way: Just add a hack at em28xx to work the same
way as ngene/ddbridge.

The code is not beautiful, but in order to fix, I would also need to touch at
tda18271c2dd. Let's do it on another time.

-

[media] Remove the double symbol increment hack from drxk_hard
    
Both ngene and ddbrige calls dvb_attach once for drxk_attach.
The logic used there, and by tda18271c2dd driver is different
from similar logic on other frontends.

The right fix is to change them to use the same logic, but,
while we don't do that, we need to patch em28xx-dvb in order
to do cope with ngene/ddbridge magic.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c
index d503558..a0e2ff5 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -6313,12 +6313,10 @@ static int drxk_c_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend
 
 static void drxk_t_release(struct dvb_frontend *fe)
 {
-#if 0
-	struct drxk_state *state = fe->demodulator_priv;
-
-	dprintk(1, "\n");
-	kfree(state);
-#endif
+	/*
+	 * There's nothing to release here, as the state struct
+	 * is already freed by drxk_c_release.
+	 */
 }
 
 static int drxk_t_init(struct dvb_frontend *fe)
@@ -6451,17 +6449,6 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config,
 		goto error;
 	*fe_t = &state->t_frontend;
 
-#ifdef CONFIG_MEDIA_ATTACH
-	/*
-	 * HACK: As this function initializes both DVB-T and DVB-C fe symbols,
-	 * and calling it twice would create the state twice, leading into
-	 * memory leaks, the right way is to call it only once. However, dvb
-	 * release functions will call symbol_put twice. So, the solution is to
-	 * artificially increment the usage count, in order to allow the
-	 * driver to be released.
-	 */
-	symbol_get(drxk_attach);
-#endif
 	return &state->c_frontend;
 
 error:
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index f8617d2..ab8a740 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -76,9 +76,10 @@ struct em28xx_dvb {
 	struct dmx_frontend        fe_mem;
 	struct dvb_net             net;
 
-	/* Due to DRX-D - probably need changes */
+	/* Due to DRX-K - probably need changes */
 	int (*gate_ctrl)(struct dvb_frontend *, int);
 	struct semaphore      pll_mutex;
+	bool			dont_attach_fe1;
 };
 
 
@@ -595,7 +596,7 @@ static void unregister_dvb(struct em28xx_dvb *dvb)
 	if (dvb->fe[1])
 		dvb_unregister_frontend(dvb->fe[1]);
 	dvb_unregister_frontend(dvb->fe[0]);
-	if (dvb->fe[1])
+	if (dvb->fe[1] && !dvb->dont_attach_fe1)
 		dvb_frontend_detach(dvb->fe[1]);
 	dvb_frontend_detach(dvb->fe[0]);
 	dvb_unregister_adapter(&dvb->adapter);
@@ -771,21 +772,22 @@ static int dvb_init(struct em28xx *dev)
 	case EM2884_BOARD_TERRATEC_H5:
 		terratec_h5_init(dev);
 
-		/* dvb->fe[1] will be DVB-C, and dvb->fe[0] will be DVB-T */
+		dvb->dont_attach_fe1 = 1;
+
 		dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap, &dvb->fe[1]);
-		if (!dvb->fe[0] || !dvb->fe[1]) {
+		if (!dvb->fe[0]) {
 			result = -EINVAL;
 			goto out_free;
 		}
+
 		/* FIXME: do we need a pll semaphore? */
 		dvb->fe[0]->sec_priv = dvb;
 		sema_init(&dvb->pll_mutex, 1);
 		dvb->gate_ctrl = dvb->fe[0]->ops.i2c_gate_ctrl;
 		dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
-		dvb->fe[1]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 		dvb->fe[1]->id = 1;
 
-		/* Attach tda18271 */
+		/* Attach tda18271 to DVB-C frontend */
 		if (dvb->fe[0]->ops.i2c_gate_ctrl)
 			dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 1);
 		if (!dvb_attach(tda18271c2dd_attach, dvb->fe[0], &dev->i2c_adap, 0x60)) {
@@ -794,8 +796,12 @@ static int dvb_init(struct em28xx *dev)
 		}
 		if (dvb->fe[0]->ops.i2c_gate_ctrl)
 			dvb->fe[0]->ops.i2c_gate_ctrl(dvb->fe[0], 0);
-		if (dvb->fe[1]->ops.i2c_gate_ctrl)
-			dvb->fe[1]->ops.i2c_gate_ctrl(dvb->fe[1], 1);
+
+		/* Hack - needed by drxk/tda18271c2dd */
+		dvb->fe[1]->tuner_priv = dvb->fe[0]->tuner_priv;
+		memcpy(&dvb->fe[1]->ops.tuner_ops,
+		       &dvb->fe[0]->ops.tuner_ops,
+		       sizeof(dvb->fe[0]->ops.tuner_ops));
 
 		break;
 	default:

  parent reply	other threads:[~2011-07-15  3:56 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-03 21:21 [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge) Oliver Endriss
2011-07-03 21:23 ` PATCH 1/5] ddbridge: Initial check-in Oliver Endriss
2011-07-03 21:24 ` [PATCH 2/5] ddbridge: Codingstyle fixes Oliver Endriss
2011-07-03 21:25 ` [PATCH 3/5] ddbridge: Allow compiling of the driver Oliver Endriss
2011-07-03 21:26 ` [PATCH 4/5] cxd2099: Fix compilation of ngene/ddbridge for DVB_CXD2099=n Oliver Endriss
2011-07-04 10:14   ` Bjørn Mork
2011-07-03 21:27 ` [PATCH 5/5] cxd2099: Update Kconfig description (ddbridge support) Oliver Endriss
2011-07-04  0:06   ` Walter Van Eetvelt
2011-07-03 22:27 ` [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge) Mauro Carvalho Chehab
2011-07-03 23:24   ` Oliver Endriss
2011-07-04  0:17     ` Mauro Carvalho Chehab
2011-07-14 23:45       ` Oliver Endriss
2011-07-15  0:47         ` Mauro Carvalho Chehab
2011-07-15  2:11           ` Oliver Endriss
2011-07-15  4:01             ` Mauro Carvalho Chehab
2011-07-15  3:56           ` Mauro Carvalho Chehab [this message]
2011-07-15  5:17             ` Oliver Endriss
2011-07-15  8:26               ` Ralph Metzler
2011-07-15 13:25                 ` Mauro Carvalho Chehab
2011-07-15 17:01                   ` Andreas Oberritter
2011-07-15 17:34                     ` Mauro Carvalho Chehab
2011-07-15 23:41                     ` Antti Palosaari
2011-07-16 12:25                       ` Mauro Carvalho Chehab
2011-07-16 14:16                         ` Antti Palosaari
2011-07-16 14:54                           ` Mauro Carvalho Chehab
2011-07-16 15:40                             ` Andreas Oberritter
2011-07-16 15:44                               ` Antti Palosaari
2011-07-16 15:53                                 ` Andreas Oberritter
2011-07-16 15:59                                   ` Antti Palosaari
2011-07-16 16:37                                   ` Rémi Denis-Courmont
2011-07-17  2:51                                     ` Andreas Oberritter
2011-07-17  7:51                                       ` Rémi Denis-Courmont
2011-07-17  0:56                                   ` Mauro Carvalho Chehab
2011-07-17  3:02                                     ` Andreas Oberritter
2011-07-17  3:59                                       ` Mauro Carvalho Chehab
2011-07-17  7:39                                     ` Rémi Denis-Courmont
2011-07-17  8:01                                       ` Mauro Carvalho Chehab
2011-07-17  1:07                                 ` Mauro Carvalho Chehab
2011-07-16 15:40                             ` Oliver Endriss
2011-11-03  7:49                               ` Steffen Barszus
2011-11-03 17:24                                 ` Lars Hanisch
2011-07-15  4:18         ` Mauro Carvalho Chehab
2011-07-15  5:21           ` Oliver Endriss
2011-07-15 12:40             ` Mauro Carvalho Chehab
2011-07-17 11:44               ` Oliver Endriss

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=4E1FBA6F.10509@redhat.com \
    --to=mchehab@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=o.endriss@gmx.de \
    --cc=rjkm@metzlerbros.de \
    /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