Skip to content

Commit 1cd3c0f

Browse files
Hans VerkuilMauro Carvalho Chehab
authored andcommitted
V4L/DVB (11022): zoran/bt819: use new notify functionality.
Bt819 needs the parent driver to drive a GPIO pin low and high in order to reset its fifo. Use the new notify callback for this. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent 98ec633 commit 1cd3c0f

6 files changed

Lines changed: 71 additions & 47 deletions

File tree

‎drivers/media/video/bt819.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232
#include <linux/types.h>
3333
#include <linux/ioctl.h>
3434
#include <linux/delay.h>
35-
#include <asm/uaccess.h>
35+
#include <linux/uaccess.h>
3636
#include <linux/i2c.h>
3737
#include <linux/i2c-id.h>
3838
#include <linux/videodev2.h>
3939
#include <media/v4l2-device.h>
4040
#include <media/v4l2-chip-ident.h>
4141
#include <media/v4l2-i2c-drv.h>
42+
#include <media/bt819.h>
4243

4344
MODULE_DESCRIPTION("Brooktree-819 video decoder driver");
4445
MODULE_AUTHOR("Mike Bernson & Dave Perks");
@@ -250,7 +251,11 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
250251

251252
v4l2_dbg(1, debug, sd, "set norm %llx\n", (unsigned long long)std);
252253

254+
if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
255+
v4l2_err(sd, "no notify found!\n");
256+
253257
if (std & V4L2_STD_NTSC) {
258+
v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
254259
bt819_setbit(decoder, 0x01, 0, 1);
255260
bt819_setbit(decoder, 0x01, 1, 0);
256261
bt819_setbit(decoder, 0x01, 5, 0);
@@ -259,6 +264,7 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
259264
/* bt819_setbit(decoder, 0x1a, 5, 1); */
260265
timing = &timing_data[1];
261266
} else if (std & V4L2_STD_PAL) {
267+
v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
262268
bt819_setbit(decoder, 0x01, 0, 1);
263269
bt819_setbit(decoder, 0x01, 1, 1);
264270
bt819_setbit(decoder, 0x01, 5, 1);
@@ -283,6 +289,7 @@ static int bt819_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
283289
bt819_write(decoder, 0x08, (timing->hscale >> 8) & 0xff);
284290
bt819_write(decoder, 0x09, timing->hscale & 0xff);
285291
decoder->norm = std;
292+
v4l2_subdev_notify(sd, BT819_FIFO_RESET_HIGH, 0);
286293
return 0;
287294
}
288295

@@ -295,7 +302,11 @@ static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro
295302
if (route->input < 0 || route->input > 7)
296303
return -EINVAL;
297304

305+
if (sd->v4l2_dev == NULL || sd->v4l2_dev->notify == NULL)
306+
v4l2_err(sd, "no notify found!\n");
307+
298308
if (decoder->input != route->input) {
309+
v4l2_subdev_notify(sd, BT819_FIFO_RESET_LOW, 0);
299310
decoder->input = route->input;
300311
/* select mode */
301312
if (decoder->input == 0) {
@@ -305,6 +316,7 @@ static int bt819_s_routing(struct v4l2_subdev *sd, const struct v4l2_routing *ro
305316
bt819_setbit(decoder, 0x0b, 6, 1);
306317
bt819_setbit(decoder, 0x1a, 1, 0);
307318
}
319+
v4l2_subdev_notify(sd, BT819_FIFO_RESET_HIGH, 0);
308320
}
309321
return 0;
310322
}

‎drivers/media/video/zoran/zoran_card.c‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <linux/i2c.h>
4040
#include <linux/i2c-algo-bit.h>
4141
#include <linux/videodev2.h>
42-
#include <media/v4l2-common.h>
4342
#include <linux/spinlock.h>
4443
#include <linux/sem.h>
4544
#include <linux/kmod.h>
@@ -48,8 +47,9 @@
4847
#include <linux/pci.h>
4948
#include <linux/interrupt.h>
5049
#include <linux/mutex.h>
51-
52-
#include <asm/io.h>
50+
#include <linux/io.h>
51+
#include <media/v4l2-common.h>
52+
#include <media/bt819.h>
5353

5454
#include "videocodec.h"
5555
#include "zoran.h"
@@ -1196,6 +1196,19 @@ zoran_setup_videocodec (struct zoran *zr,
11961196
return m;
11971197
}
11981198

1199+
static int zoran_subdev_notify(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
1200+
{
1201+
struct zoran *zr = to_zoran(sd->v4l2_dev);
1202+
1203+
/* Bt819 needs to reset its FIFO buffer using #FRST pin and
1204+
LML33 card uses GPIO(7) for that. */
1205+
if (cmd == BT819_FIFO_RESET_LOW)
1206+
GPIO(zr, 7, 0);
1207+
else if (cmd == BT819_FIFO_RESET_HIGH)
1208+
GPIO(zr, 7, 1);
1209+
return 0;
1210+
}
1211+
11991212
/*
12001213
* Scan for a Buz card (actually for the PCI controller ZR36057),
12011214
* request the irq and map the io memory
@@ -1226,6 +1239,7 @@ static int __devinit zoran_probe(struct pci_dev *pdev,
12261239
ZORAN_NAME, __func__);
12271240
return -ENOMEM;
12281241
}
1242+
zr->v4l2_dev.notify = zoran_subdev_notify;
12291243
if (v4l2_device_register(&pdev->dev, &zr->v4l2_dev))
12301244
goto zr_free_mem;
12311245
zr->pci_dev = pdev;

‎drivers/media/video/zoran/zoran_device.c‎

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,8 +1584,8 @@ zoran_init_hardware (struct zoran *zr)
15841584
route.input = zr->card.input[zr->input].muxsel;
15851585

15861586
decoder_call(zr, core, init, 0);
1587-
decoder_s_std(zr, zr->norm);
1588-
decoder_s_routing(zr, &route);
1587+
decoder_call(zr, tuner, s_std, zr->norm);
1588+
decoder_call(zr, video, s_routing, &route);
15891589

15901590
encoder_call(zr, core, init, 0);
15911591
encoder_call(zr, video, s_std_output, zr->norm);
@@ -1650,35 +1650,3 @@ zr36057_init_vfe (struct zoran *zr)
16501650
reg |= ZR36057_VDCR_Triton;
16511651
btwrite(reg, ZR36057_VDCR);
16521652
}
1653-
1654-
/*
1655-
* Interface to decoder and encoder chips using i2c bus
1656-
*/
1657-
1658-
int decoder_s_std(struct zoran *zr, v4l2_std_id std)
1659-
{
1660-
int res;
1661-
1662-
/* Bt819 needs to reset its FIFO buffer using #FRST pin and
1663-
LML33 card uses GPIO(7) for that. */
1664-
if (zr->card.type == LML33)
1665-
GPIO(zr, 7, 0);
1666-
res = decoder_call(zr, tuner, s_std, std);
1667-
if (zr->card.type == LML33)
1668-
GPIO(zr, 7, 1); /* Pull #FRST high. */
1669-
return res;
1670-
}
1671-
1672-
int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route)
1673-
{
1674-
int res;
1675-
1676-
/* Bt819 needs to reset its FIFO buffer using #FRST pin and
1677-
LML33 card uses GPIO(7) for that. */
1678-
if (zr->card.type == LML33)
1679-
GPIO(zr, 7, 0);
1680-
res = decoder_call(zr, video, s_routing, route);
1681-
if (zr->card.type == LML33)
1682-
GPIO(zr, 7, 1); /* Pull #FRST high. */
1683-
return res;
1684-
}

‎drivers/media/video/zoran/zoran_device.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,4 @@ extern int pass_through;
9292
#define encoder_call(zr, o, f, args...) \
9393
v4l2_subdev_call(zr->encoder, o, f, ##args)
9494

95-
int decoder_s_std(struct zoran *zr, v4l2_std_id std);
96-
int decoder_s_routing(struct zoran *zr, struct v4l2_routing *route);
97-
9895
#endif /* __ZORAN_DEVICE_H__ */

‎drivers/media/video/zoran/zoran_driver.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ zoran_set_norm (struct zoran *zr,
14491449
v4l2_std_id std = 0;
14501450

14511451
decoder_call(zr, video, querystd, &std);
1452-
decoder_s_std(zr, std);
1452+
decoder_call(zr, tuner, s_std, std);
14531453

14541454
/* let changes come into effect */
14551455
ssleep(2);
@@ -1461,7 +1461,7 @@ zoran_set_norm (struct zoran *zr,
14611461
"%s: %s - no norm detected\n",
14621462
ZR_DEVNAME(zr), __func__);
14631463
/* reset norm */
1464-
decoder_s_std(zr, zr->norm);
1464+
decoder_call(zr, tuner, s_std, zr->norm);
14651465
return -EIO;
14661466
}
14671467

@@ -1480,7 +1480,7 @@ zoran_set_norm (struct zoran *zr,
14801480
if (on)
14811481
zr36057_overlay(zr, 0);
14821482

1483-
decoder_s_std(zr, norm);
1483+
decoder_call(zr, tuner, s_std, norm);
14841484
encoder_call(zr, video, s_std_output, norm);
14851485

14861486
if (on)
@@ -1522,7 +1522,7 @@ zoran_set_input (struct zoran *zr,
15221522
route.input = zr->card.input[input].muxsel;
15231523
zr->input = input;
15241524

1525-
decoder_s_routing(zr, &route);
1525+
decoder_call(zr, video, s_routing, &route);
15261526

15271527
return 0;
15281528
}
@@ -1775,7 +1775,7 @@ static long zoran_default(struct file *file, void *__fh, int cmd, void *arg)
17751775
goto gstat_unlock_and_return;
17761776
}
17771777

1778-
decoder_s_routing(zr, &route);
1778+
decoder_call(zr, video, s_routing, &route);
17791779

17801780
/* sleep 1 second */
17811781
ssleep(1);
@@ -1786,7 +1786,7 @@ static long zoran_default(struct file *file, void *__fh, int cmd, void *arg)
17861786

17871787
/* restore previous input and norm */
17881788
route.input = zr->card.input[zr->input].muxsel;
1789-
decoder_s_routing(zr, &route);
1789+
decoder_call(zr, video, s_routing, &route);
17901790
gstat_unlock_and_return:
17911791
mutex_unlock(&zr->resource_lock);
17921792

‎include/media/bt819.h‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
bt819.h - bt819 notifications
3+
4+
Copyright (C) 2009 Hans Verkuil (hverkuil@xs4all.nl)
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software
18+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
*/
20+
21+
#ifndef _BT819_H_
22+
#define _BT819_H_
23+
24+
#include <linux/ioctl.h>
25+
26+
/* v4l2_device notifications. */
27+
28+
/* Needed to reset the FIFO buffer when changing the input
29+
or the video standard. */
30+
#define BT819_FIFO_RESET_LOW _IO('b', 0)
31+
#define BT819_FIFO_RESET_HIGH _IO('b', 1)
32+
33+
#endif

0 commit comments

Comments
 (0)