diff options
author | Oliver Endriss <o.endriss@gmx.de> | 2006-07-18 21:55:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-07-29 16:22:23 -0400 |
commit | 32e4c3a5622e832938aa0272e21a292564ff090a (patch) | |
tree | defe0d2b1566a6438b52113e43f8536eb669cdcc /drivers/media | |
parent | 3117beec7e43f91ce156cacf033a712c7e22737d (diff) |
V4L/DVB (4323): [budget/budget-av/budget-ci/budget-patch drivers] fixed DMA start/stop code
Fix bug reported by Andrew de Quincey:
After cold boot the saa7146 DMA did not start if the demuxer was opened
before the frontend has locked to the signal.
DMA transfers will be started now if (and only if)
the frontend is locked and data should be sent to the demuxer.
Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/ttpci/budget-av.c | 3 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget-ci.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget-core.c | 57 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget-patch.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/ttpci/budget.h | 7 |
6 files changed, 57 insertions, 16 deletions
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 5f111d407730..2d21fec23b4d 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
@@ -1303,6 +1303,9 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1303 | budget_av->budget.dvb_adapter.priv = budget_av; | 1303 | budget_av->budget.dvb_adapter.priv = budget_av; |
1304 | frontend_init(budget_av); | 1304 | frontend_init(budget_av); |
1305 | ciintf_init(budget_av); | 1305 | ciintf_init(budget_av); |
1306 | |||
1307 | ttpci_budget_init_hooks(&budget_av->budget); | ||
1308 | |||
1306 | return 0; | 1309 | return 0; |
1307 | } | 1310 | } |
1308 | 1311 | ||
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 4b966eea3834..ffbbb3e34be4 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
@@ -1101,6 +1101,8 @@ static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio | |||
1101 | budget_ci->budget.dvb_adapter.priv = budget_ci; | 1101 | budget_ci->budget.dvb_adapter.priv = budget_ci; |
1102 | frontend_init(budget_ci); | 1102 | frontend_init(budget_ci); |
1103 | 1103 | ||
1104 | ttpci_budget_init_hooks(&budget_ci->budget); | ||
1105 | |||
1104 | return 0; | 1106 | return 0; |
1105 | } | 1107 | } |
1106 | 1108 | ||
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c index e4cf7775e07f..e15562f81664 100644 --- a/drivers/media/dvb/ttpci/budget-core.c +++ b/drivers/media/dvb/ttpci/budget-core.c | |||
@@ -63,9 +63,6 @@ static int stop_ts_capture(struct budget *budget) | |||
63 | { | 63 | { |
64 | dprintk(2, "budget: %p\n", budget); | 64 | dprintk(2, "budget: %p\n", budget); |
65 | 65 | ||
66 | if (--budget->feeding) | ||
67 | return budget->feeding; | ||
68 | |||
69 | saa7146_write(budget->dev, MC1, MASK_20); // DMA3 off | 66 | saa7146_write(budget->dev, MC1, MASK_20); // DMA3 off |
70 | SAA7146_IER_DISABLE(budget->dev, MASK_10); | 67 | SAA7146_IER_DISABLE(budget->dev, MASK_10); |
71 | return 0; | 68 | return 0; |
@@ -77,8 +74,8 @@ static int start_ts_capture(struct budget *budget) | |||
77 | 74 | ||
78 | dprintk(2, "budget: %p\n", budget); | 75 | dprintk(2, "budget: %p\n", budget); |
79 | 76 | ||
80 | if (budget->feeding) | 77 | if (!budget->feeding || !budget->fe_synced) |
81 | return ++budget->feeding; | 78 | return 0; |
82 | 79 | ||
83 | saa7146_write(dev, MC1, MASK_20); // DMA3 off | 80 | saa7146_write(dev, MC1, MASK_20); // DMA3 off |
84 | 81 | ||
@@ -139,7 +136,33 @@ static int start_ts_capture(struct budget *budget) | |||
139 | SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */ | 136 | SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */ |
140 | saa7146_write(dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */ | 137 | saa7146_write(dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */ |
141 | 138 | ||
142 | return ++budget->feeding; | 139 | return 0; |
140 | } | ||
141 | |||
142 | static int budget_read_fe_status(struct dvb_frontend *fe, fe_status_t *status) | ||
143 | { | ||
144 | struct budget *budget = (struct budget *) fe->dvb->priv; | ||
145 | int synced; | ||
146 | int ret; | ||
147 | |||
148 | if (budget->read_fe_status) | ||
149 | ret = budget->read_fe_status(fe, status); | ||
150 | else | ||
151 | ret = -EINVAL; | ||
152 | |||
153 | if (!ret) { | ||
154 | synced = (*status & FE_HAS_LOCK); | ||
155 | if (synced != budget->fe_synced) { | ||
156 | budget->fe_synced = synced; | ||
157 | spin_lock(&budget->feedlock); | ||
158 | if (synced) | ||
159 | start_ts_capture(budget); | ||
160 | else | ||
161 | stop_ts_capture(budget); | ||
162 | spin_unlock(&budget->feedlock); | ||
163 | } | ||
164 | } | ||
165 | return ret; | ||
143 | } | 166 | } |
144 | 167 | ||
145 | static void vpeirq(unsigned long data) | 168 | static void vpeirq(unsigned long data) |
@@ -267,7 +290,7 @@ static int budget_start_feed(struct dvb_demux_feed *feed) | |||
267 | { | 290 | { |
268 | struct dvb_demux *demux = feed->demux; | 291 | struct dvb_demux *demux = feed->demux; |
269 | struct budget *budget = (struct budget *) demux->priv; | 292 | struct budget *budget = (struct budget *) demux->priv; |
270 | int status; | 293 | int status = 0; |
271 | 294 | ||
272 | dprintk(2, "budget: %p\n", budget); | 295 | dprintk(2, "budget: %p\n", budget); |
273 | 296 | ||
@@ -276,7 +299,8 @@ static int budget_start_feed(struct dvb_demux_feed *feed) | |||
276 | 299 | ||
277 | spin_lock(&budget->feedlock); | 300 | spin_lock(&budget->feedlock); |
278 | feed->pusi_seen = 0; /* have a clean section start */ | 301 | feed->pusi_seen = 0; /* have a clean section start */ |
279 | status = start_ts_capture(budget); | 302 | if (budget->feeding++ == 0) |
303 | status = start_ts_capture(budget); | ||
280 | spin_unlock(&budget->feedlock); | 304 | spin_unlock(&budget->feedlock); |
281 | return status; | 305 | return status; |
282 | } | 306 | } |
@@ -285,12 +309,13 @@ static int budget_stop_feed(struct dvb_demux_feed *feed) | |||
285 | { | 309 | { |
286 | struct dvb_demux *demux = feed->demux; | 310 | struct dvb_demux *demux = feed->demux; |
287 | struct budget *budget = (struct budget *) demux->priv; | 311 | struct budget *budget = (struct budget *) demux->priv; |
288 | int status; | 312 | int status = 0; |
289 | 313 | ||
290 | dprintk(2, "budget: %p\n", budget); | 314 | dprintk(2, "budget: %p\n", budget); |
291 | 315 | ||
292 | spin_lock(&budget->feedlock); | 316 | spin_lock(&budget->feedlock); |
293 | status = stop_ts_capture(budget); | 317 | if (--budget->feeding == 0) |
318 | status = stop_ts_capture(budget); | ||
294 | spin_unlock(&budget->feedlock); | 319 | spin_unlock(&budget->feedlock); |
295 | return status; | 320 | return status; |
296 | } | 321 | } |
@@ -470,6 +495,14 @@ err: | |||
470 | return ret; | 495 | return ret; |
471 | } | 496 | } |
472 | 497 | ||
498 | void ttpci_budget_init_hooks(struct budget *budget) | ||
499 | { | ||
500 | if (budget->dvb_frontend && !budget->read_fe_status) { | ||
501 | budget->read_fe_status = budget->dvb_frontend->ops.read_status; | ||
502 | budget->dvb_frontend->ops.read_status = budget_read_fe_status; | ||
503 | } | ||
504 | } | ||
505 | |||
473 | int ttpci_budget_deinit(struct budget *budget) | 506 | int ttpci_budget_deinit(struct budget *budget) |
474 | { | 507 | { |
475 | struct saa7146_dev *dev = budget->dev; | 508 | struct saa7146_dev *dev = budget->dev; |
@@ -508,11 +541,8 @@ void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port) | |||
508 | spin_lock(&budget->feedlock); | 541 | spin_lock(&budget->feedlock); |
509 | budget->video_port = video_port; | 542 | budget->video_port = video_port; |
510 | if (budget->feeding) { | 543 | if (budget->feeding) { |
511 | int oldfeeding = budget->feeding; | ||
512 | budget->feeding = 1; | ||
513 | stop_ts_capture(budget); | 544 | stop_ts_capture(budget); |
514 | start_ts_capture(budget); | 545 | start_ts_capture(budget); |
515 | budget->feeding = oldfeeding; | ||
516 | } | 546 | } |
517 | spin_unlock(&budget->feedlock); | 547 | spin_unlock(&budget->feedlock); |
518 | } | 548 | } |
@@ -520,6 +550,7 @@ void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port) | |||
520 | EXPORT_SYMBOL_GPL(ttpci_budget_debiread); | 550 | EXPORT_SYMBOL_GPL(ttpci_budget_debiread); |
521 | EXPORT_SYMBOL_GPL(ttpci_budget_debiwrite); | 551 | EXPORT_SYMBOL_GPL(ttpci_budget_debiwrite); |
522 | EXPORT_SYMBOL_GPL(ttpci_budget_init); | 552 | EXPORT_SYMBOL_GPL(ttpci_budget_init); |
553 | EXPORT_SYMBOL_GPL(ttpci_budget_init_hooks); | ||
523 | EXPORT_SYMBOL_GPL(ttpci_budget_deinit); | 554 | EXPORT_SYMBOL_GPL(ttpci_budget_deinit); |
524 | EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler); | 555 | EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler); |
525 | EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port); | 556 | EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port); |
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c index ee60ce90a400..57227441891e 100644 --- a/drivers/media/dvb/ttpci/budget-patch.c +++ b/drivers/media/dvb/ttpci/budget-patch.c | |||
@@ -617,6 +617,8 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte | |||
617 | budget->dvb_adapter.priv = budget; | 617 | budget->dvb_adapter.priv = budget; |
618 | frontend_init(budget); | 618 | frontend_init(budget); |
619 | 619 | ||
620 | ttpci_budget_init_hooks(budget); | ||
621 | |||
620 | return 0; | 622 | return 0; |
621 | } | 623 | } |
622 | 624 | ||
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 1b4d884a9709..863dffb4ed8e 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
@@ -471,6 +471,8 @@ static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_ | |||
471 | budget->dvb_adapter.priv = budget; | 471 | budget->dvb_adapter.priv = budget; |
472 | frontend_init(budget); | 472 | frontend_init(budget); |
473 | 473 | ||
474 | ttpci_budget_init_hooks(budget); | ||
475 | |||
474 | return 0; | 476 | return 0; |
475 | } | 477 | } |
476 | 478 | ||
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h index ecea3a13030e..e8a5c79178e1 100644 --- a/drivers/media/dvb/ttpci/budget.h +++ b/drivers/media/dvb/ttpci/budget.h | |||
@@ -52,9 +52,6 @@ struct budget { | |||
52 | struct dmx_frontend hw_frontend; | 52 | struct dmx_frontend hw_frontend; |
53 | struct dmx_frontend mem_frontend; | 53 | struct dmx_frontend mem_frontend; |
54 | 54 | ||
55 | int fe_synced; | ||
56 | struct mutex pid_mutex; | ||
57 | |||
58 | int ci_present; | 55 | int ci_present; |
59 | int video_port; | 56 | int video_port; |
60 | 57 | ||
@@ -74,6 +71,9 @@ struct budget { | |||
74 | 71 | ||
75 | struct dvb_adapter dvb_adapter; | 72 | struct dvb_adapter dvb_adapter; |
76 | struct dvb_frontend *dvb_frontend; | 73 | struct dvb_frontend *dvb_frontend; |
74 | int (*read_fe_status)(struct dvb_frontend *fe, fe_status_t *status); | ||
75 | int fe_synced; | ||
76 | |||
77 | void *priv; | 77 | void *priv; |
78 | }; | 78 | }; |
79 | 79 | ||
@@ -106,6 +106,7 @@ static struct saa7146_pci_extension_data x_var = { \ | |||
106 | extern int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | 106 | extern int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, |
107 | struct saa7146_pci_extension_data *info, | 107 | struct saa7146_pci_extension_data *info, |
108 | struct module *owner); | 108 | struct module *owner); |
109 | extern void ttpci_budget_init_hooks(struct budget *budget); | ||
109 | extern int ttpci_budget_deinit(struct budget *budget); | 110 | extern int ttpci_budget_deinit(struct budget *budget); |
110 | extern void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 * isr); | 111 | extern void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 * isr); |
111 | extern void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port); | 112 | extern void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port); |