Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
888c9d64
Commit
888c9d64
authored
Nov 25, 2002
by
Alan Cox
Committed by
Linus Torvalds
Nov 25, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] dvb updates - mostly typedef to structs and other similar cleaning
parent
a913beae
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
2377 additions
and
1438 deletions
+2377
-1438
drivers/media/dvb/av7110/Makefile
drivers/media/dvb/av7110/Makefile
+2
-0
drivers/media/dvb/av7110/av7110.c
drivers/media/dvb/av7110/av7110.c
+150
-140
drivers/media/dvb/av7110/av7110.h
drivers/media/dvb/av7110/av7110.h
+9
-9
drivers/media/dvb/av7110/saa7146.c
drivers/media/dvb/av7110/saa7146.c
+1
-1
drivers/media/dvb/av7110/saa7146_core.c
drivers/media/dvb/av7110/saa7146_core.c
+28
-34
drivers/media/dvb/av7110/saa7146_core.h
drivers/media/dvb/av7110/saa7146_core.h
+11
-16
drivers/media/dvb/av7110/saa7146_v4l.c
drivers/media/dvb/av7110/saa7146_v4l.c
+0
-1
drivers/media/dvb/dvb-core/dmxdev.c
drivers/media/dvb/dvb-core/dmxdev.c
+118
-119
drivers/media/dvb/dvb-core/dmxdev.h
drivers/media/dvb/dvb-core/dmxdev.h
+5
-5
drivers/media/dvb/dvb-core/dvb_demux.c
drivers/media/dvb/dvb-core/dvb_demux.c
+77
-77
drivers/media/dvb/dvb-core/dvb_demux.h
drivers/media/dvb/dvb-core/dvb_demux.h
+21
-21
drivers/media/dvb/dvb-core/dvb_filter.c
drivers/media/dvb/dvb-core/dvb_filter.c
+790
-751
drivers/media/dvb/dvb-core/dvb_filter.h
drivers/media/dvb/dvb-core/dvb_filter.h
+13
-28
drivers/media/dvb/dvb-core/dvb_frontend.c
drivers/media/dvb/dvb-core/dvb_frontend.c
+39
-29
drivers/media/dvb/dvb-core/dvb_frontend.h
drivers/media/dvb/dvb-core/dvb_frontend.h
+4
-4
drivers/media/dvb/dvb-core/dvb_i2c.c
drivers/media/dvb/dvb-core/dvb_i2c.c
+3
-3
drivers/media/dvb/dvb-core/dvb_i2c.h
drivers/media/dvb/dvb-core/dvb_i2c.h
+3
-3
drivers/media/dvb/dvb-core/dvb_ksyms.c
drivers/media/dvb/dvb-core/dvb_ksyms.c
+14
-14
drivers/media/dvb/dvb-core/dvb_net.c
drivers/media/dvb/dvb-core/dvb_net.c
+12
-15
drivers/media/dvb/dvb-core/dvb_net.h
drivers/media/dvb/dvb-core/dvb_net.h
+2
-2
drivers/media/dvb/dvb-core/dvbdev.c
drivers/media/dvb/dvb-core/dvbdev.c
+33
-100
drivers/media/dvb/dvb-core/dvbdev.h
drivers/media/dvb/dvb-core/dvbdev.h
+22
-23
drivers/media/dvb/frontends/Kconfig
drivers/media/dvb/frontends/Kconfig
+24
-0
drivers/media/dvb/frontends/Makefile
drivers/media/dvb/frontends/Makefile
+2
-0
drivers/media/dvb/frontends/alps_bsru6.c
drivers/media/dvb/frontends/alps_bsru6.c
+81
-36
drivers/media/dvb/frontends/alps_bsrv2.c
drivers/media/dvb/frontends/alps_bsrv2.c
+1
-1
drivers/media/dvb/frontends/alps_tdlb7.c
drivers/media/dvb/frontends/alps_tdlb7.c
+437
-0
drivers/media/dvb/frontends/alps_tdmb7.c
drivers/media/dvb/frontends/alps_tdmb7.c
+468
-0
drivers/media/dvb/frontends/ves1820.c
drivers/media/dvb/frontends/ves1820.c
+7
-6
No files found.
drivers/media/dvb/av7110/Makefile
View file @
888c9d64
...
...
@@ -6,5 +6,7 @@ dvb-ttpci-objs := saa7146_core.o saa7146_v4l.o av7110.o av7110_ir.o
obj-$(CONFIG_DVB_AV7110)
+=
dvb-ttpci.o
EXTRA_CFLAGS
=
-Idrivers
/media/dvb/dvb-core/
include
$(TOPDIR)/Rules.make
drivers/media/dvb/av7110/av7110.c
View file @
888c9d64
...
...
@@ -89,7 +89,7 @@ static int outcom(av7110_t *av7110, int type, int com, int num, ...);
static
void
SetMode
(
av7110_t
*
av7110
,
int
mode
);
void
pes_to_ts
(
u8
const
*
buf
,
long
int
length
,
u16
pid
,
p2t_t
*
p
);
void
p_to_t
(
u8
const
*
buf
,
long
int
length
,
u16
pid
,
u8
*
counter
,
dvb_demux_feed_t
*
feed
);
void
p_to_t
(
u8
const
*
buf
,
long
int
length
,
u16
pid
,
u8
*
counter
,
struct
dvb_demux_feed
*
feed
);
static
u32
vidmem
=
0
;
static
u32
vidlow
=
0
;
...
...
@@ -392,9 +392,9 @@ static int arm_thread(void *data)
static
int
record_cb
(
pes2ts_t
*
p2t
,
u8
*
buf
,
size_t
len
)
record_cb
(
dvb_filter_
pes2ts_t
*
p2t
,
u8
*
buf
,
size_t
len
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
p2t
->
priv
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
p2t
->
priv
;
if
(
!
(
dvbdmxfeed
->
ts_type
&
TS_PACKET
))
return
0
;
...
...
@@ -404,13 +404,13 @@ record_cb(pes2ts_t *p2t, u8 *buf, size_t len)
return
dvbdmxfeed
->
cb
.
ts
(
buf
,
len
,
0
,
0
,
&
dvbdmxfeed
->
feed
.
ts
,
DMX_OK
);
else
return
pes2ts
(
p2t
,
buf
,
len
);
return
dvb_filter_
pes2ts
(
p2t
,
buf
,
len
);
}
static
int
pes2ts_cb
(
void
*
priv
,
unsigned
char
*
data
)
dvb_filter_
pes2ts_cb
(
void
*
priv
,
unsigned
char
*
data
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
priv
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
priv
;
dvbdmxfeed
->
cb
.
ts
(
data
,
188
,
0
,
0
,
&
dvbdmxfeed
->
feed
.
ts
,
...
...
@@ -420,9 +420,9 @@ pes2ts_cb(void *priv, unsigned char *data)
static
int
AV_StartRecord
(
av7110_t
*
av7110
,
int
av
,
dvb_demux_feed_t
*
dvbdmxfeed
)
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
if
(
av7110
->
playing
||
(
av7110
->
rec_mode
&
av
))
return
-
EBUSY
;
...
...
@@ -432,20 +432,30 @@ AV_StartRecord(av7110_t *av7110, int av,
switch
(
av7110
->
rec_mode
)
{
case
RP_AUDIO
:
pes2ts_init
(
&
av7110
->
p2t
[
0
],
dvbdmx
->
pesfilter
[
0
]
->
pid
,
pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
0
]);
dvb_filter_pes2ts_init
(
&
av7110
->
p2t
[
0
],
dvbdmx
->
pesfilter
[
0
]
->
pid
,
dvb_filter_pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
0
]);
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
__Record
,
2
,
AudioPES
,
0
);
break
;
case
RP_VIDEO
:
pes2ts_init
(
&
av7110
->
p2t
[
1
],
dvbdmx
->
pesfilter
[
1
]
->
pid
,
pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
1
]);
dvb_filter_pes2ts_init
(
&
av7110
->
p2t
[
1
],
dvbdmx
->
pesfilter
[
1
]
->
pid
,
dvb_filter_pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
1
]);
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
__Record
,
2
,
VideoPES
,
0
);
break
;
case
RP_AV
:
pes2ts_init
(
&
av7110
->
p2t
[
0
],
dvbdmx
->
pesfilter
[
0
]
->
pid
,
pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
0
]);
pes2ts_init
(
&
av7110
->
p2t
[
1
],
dvbdmx
->
pesfilter
[
1
]
->
pid
,
pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
1
]);
dvb_filter_pes2ts_init
(
&
av7110
->
p2t
[
0
],
dvbdmx
->
pesfilter
[
0
]
->
pid
,
dvb_filter_pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
0
]);
dvb_filter_pes2ts_init
(
&
av7110
->
p2t
[
1
],
dvbdmx
->
pesfilter
[
1
]
->
pid
,
dvb_filter_pes2ts_cb
,
(
void
*
)
dvbdmx
->
pesfilter
[
1
]);
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
__Record
,
2
,
AV_PES
,
0
);
break
;
}
...
...
@@ -463,8 +473,8 @@ AV_StartPlay(av7110_t *av7110, int av)
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
__Stop
,
0
);
if
(
av7110
->
playing
==
RP_NONE
)
{
reset_ipack
(
&
av7110
->
ipack
[
0
]);
reset_ipack
(
&
av7110
->
ipack
[
1
]);
dvb_filter_ipack_reset
(
&
av7110
->
ipack
[
0
]);
dvb_filter_ipack_reset
(
&
av7110
->
ipack
[
1
]);
}
av7110
->
playing
|=
av
;
...
...
@@ -814,7 +824,7 @@ void CI_handle(av7110_t *av7110, u8 *data, u16 len)
static
inline
int
DvbDmxFilterCallback
(
u8
*
buffer1
,
size_t
buffer1_len
,
u8
*
buffer2
,
size_t
buffer2_len
,
dvb_demux_filter_t
*
dvbdmxfilter
,
struct
dvb_demux_filter
*
dvbdmxfilter
,
dmx_success_t
success
,
av7110_t
*
av7110
)
{
...
...
@@ -896,7 +906,7 @@ static void fidbirq(struct saa7146* saa, void *data)
// FIXME: use bottom half or tasklet
if (av7110->feeding && mem[0]==0x47)
DvbDmxSWFilterP
ackets(&av7110->demux, mem, 512);
dvb_dmx_swfilter_p
ackets(&av7110->demux, mem, 512);
}
#else
static
...
...
@@ -922,7 +932,7 @@ void fidbirq (unsigned long data)
}
else
{
if
(
av7110
->
ttbp
>
1000
*
188
&&
av7110
->
ttbp
<
1024
*
188
)
{
if
(
av7110
->
feeding
)
DvbDmxSWFilterP
ackets
(
&
av7110
->
demux
,
dvb_dmx_swfilter_p
ackets
(
&
av7110
->
demux
,
mem
+
av7110
->
ttbp
,
1024
-
av7110
->
ttbp
/
188
);
}
...
...
@@ -937,7 +947,7 @@ void fidbirq (unsigned long data)
// FIXME: use bottom half or tasklet
if
(
av7110
->
feeding
&&
mem
[
0
]
==
0x47
)
DvbDmxSWFilterP
ackets
(
&
av7110
->
demux
,
mem
,
num
);
dvb_dmx_swfilter_p
ackets
(
&
av7110
->
demux
,
mem
,
num
);
}
#endif
...
...
@@ -1001,7 +1011,7 @@ void debiirq (unsigned long data)
switch
(
type
&
0xff
)
{
case
DATA_TS_RECORD
:
DvbDmxSWFilterP
ackets
(
&
av7110
->
demux
,
dvb_dmx_swfilter_p
ackets
(
&
av7110
->
demux
,
(
const
u8
*
)
av7110
->
debi_virt
,
av7110
->
debilen
/
188
);
spin_lock
(
&
av7110
->
debilock
);
...
...
@@ -2008,8 +2018,8 @@ firmversion(av7110_t *av7110)
av7110
->
arm_app
=
(
buf
[
6
]
<<
16
)
+
buf
[
7
];
av7110
->
avtype
=
(
buf
[
8
]
<<
16
)
+
buf
[
9
];
printk
(
"
av7110 (%d): AV711%d - firm %08x, rtsl %08x, vid %08x, app %08x
\n
"
,
av7110
->
saa
->
dvb_adapter
->
num
,
av7110
->
avtype
,
av7110
->
arm_fw
,
printk
(
"
DVB: AV711%d(%d) - firm %08x, rtsl %08x, vid %08x, app %08x
\n
"
,
av7110
->
avtype
,
av7110
->
saa
->
dvb_adapter
->
num
,
av7110
->
arm_fw
,
av7110
->
arm_rtsl
,
av7110
->
arm_vid
,
av7110
->
arm_app
);
return
;
...
...
@@ -2483,9 +2493,12 @@ dvb_play(av7110_t *av7110, const u8 *buf,
if
(
umem
)
{
if
(
copy_from_user
(
av7110
->
kbuf
[
type
],
buf
,
n
))
return
-
EFAULT
;
instant_repack
(
av7110
->
kbuf
[
type
],
n
,
&
av7110
->
ipack
[
type
]);
}
else
instant_repack
((
u8
*
)
buf
,
n
,
&
av7110
->
ipack
[
type
]);
dvb_filter_instant_repack
(
av7110
->
kbuf
[
type
],
n
,
&
av7110
->
ipack
[
type
]);
}
else
{
dvb_filter_instant_repack
((
u8
*
)
buf
,
n
,
&
av7110
->
ipack
[
type
]);
}
todo
-=
n
;
buf
+=
n
;
}
...
...
@@ -2517,7 +2530,8 @@ dvb_aplay(av7110_t *av7110, const u8 *buf,
n
=
IPACKS
*
2
;
if
(
copy_from_user
(
av7110
->
kbuf
[
type
],
buf
,
n
))
return
-
EFAULT
;
instant_repack
(
av7110
->
kbuf
[
type
],
n
,
&
av7110
->
ipack
[
type
]);
dvb_filter_instant_repack
(
av7110
->
kbuf
[
type
],
n
,
&
av7110
->
ipack
[
type
]);
// memcpy(dvb->kbuf[type], buf, n);
todo
-=
n
;
buf
+=
n
;
...
...
@@ -2525,7 +2539,7 @@ dvb_aplay(av7110_t *av7110, const u8 *buf,
return
count
-
todo
;
}
void
init_p2t
(
p2t_t
*
p
,
dvb_demux_feed_t
*
feed
)
void
init_p2t
(
p2t_t
*
p
,
struct
dvb_demux_feed
*
feed
)
{
memset
(
p
->
pes
,
0
,
TS_SIZE
);
p
->
counter
=
0
;
...
...
@@ -2721,7 +2735,7 @@ int write_ts_header2(u16 pid, u8 *counter, int pes_start, u8 *buf, u8 length)
void
p_to_t
(
u8
const
*
buf
,
long
int
length
,
u16
pid
,
u8
*
counter
,
dvb_demux_feed_t
*
feed
)
struct
dvb_demux_feed
*
feed
)
{
int
l
,
pes_start
;
...
...
@@ -3104,7 +3118,7 @@ static int dvb_mmap(struct file* file, struct vm_area_struct *vma)
static
unsigned
int
dvb_audio_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
int
mask
=
0
;
...
...
@@ -3124,24 +3138,24 @@ static unsigned int dvb_audio_poll(struct file *file, poll_table *wait)
static
struct
file_operations
dvb_fops
=
{
ioctl:
dvb_ioctl
,
mmap:
dvb_mmap
,
llseek:
no_llseek
.
ioctl
=
dvb_ioctl
,
.
mmap
=
dvb_mmap
,
.
llseek
=
no_llseek
};
/* template for video_device-structure */
static
struct
video_device
dvb_template
=
{
owner:
THIS_MODULE
,
name:
"DVB Board"
,
type:
VID_TYPE_TUNER
|
.
owner
=
THIS_MODULE
,
.
name
=
"DVB Board"
,
.
type
=
VID_TYPE_TUNER
|
VID_TYPE_CAPTURE
|
VID_TYPE_OVERLAY
|
VID_TYPE_CLIPPING
|
VID_TYPE_FRAMERAM
|
VID_TYPE_SCALES
,
hardware:
VID_HARDWARE_SAA7146
,
fops:
&
dvb_fops
.
hardware
=
VID_HARDWARE_SAA7146
,
.
fops
=
&
dvb_fops
};
...
...
@@ -3182,9 +3196,9 @@ static inline int vid_unregister(av7110_t *av7110)
******************************************************************************/
static
int
StartHWFilter
(
dvb_demux_filter_t
*
dvbdmxfilter
)
StartHWFilter
(
struct
dvb_demux_filter
*
dvbdmxfilter
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
dvbdmxfilter
->
feed
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
dvbdmxfilter
->
feed
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmxfeed
->
demux
->
priv
;
u16
buf
[
20
];
int
ret
,
i
;
...
...
@@ -3220,7 +3234,7 @@ StartHWFilter(dvb_demux_filter_t *dvbdmxfilter)
}
static
int
StopHWFilter
(
dvb_demux_filter_t
*
dvbdmxfilter
)
StopHWFilter
(
struct
dvb_demux_filter
*
dvbdmxfilter
)
{
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmxfilter
->
feed
->
demux
->
priv
;
u16
buf
[
3
];
...
...
@@ -3252,9 +3266,9 @@ StopHWFilter(dvb_demux_filter_t *dvbdmxfilter)
static
int
dvb_write_to_decoder
(
dvb_demux_feed_t
*
dvbdmxfeed
,
u8
*
buf
,
size_t
count
)
dvb_write_to_decoder
(
struct
dvb_demux_feed
*
dvbdmxfeed
,
u8
*
buf
,
size_t
count
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmx
->
priv
;
ipack
*
ipack
=&
av7110
->
ipack
[
dvbdmxfeed
->
pes_type
];
...
...
@@ -3277,7 +3291,7 @@ dvb_write_to_decoder(dvb_demux_feed_t *dvbdmxfeed, u8 *buf, size_t count)
return
-
1
;
}
if
(
buf
[
1
]
&
0x40
)
send_ipack_rest
(
ipack
);
dvb_filter_ipack_flush
(
ipack
);
if
(
buf
[
3
]
&
0x20
)
{
// adaptation field?
count
-=
buf
[
4
]
+
1
;
...
...
@@ -3287,14 +3301,15 @@ dvb_write_to_decoder(dvb_demux_feed_t *dvbdmxfeed, u8 *buf, size_t count)
}
}
instant_repack
(
buf
+
4
,
count
-
4
,
&
av7110
->
ipack
[
dvbdmxfeed
->
pes_type
]);
dvb_filter_instant_repack
(
buf
+
4
,
count
-
4
,
&
av7110
->
ipack
[
dvbdmxfeed
->
pes_type
]);
return
0
;
}
static
void
dvb_feed_start_pid
(
dvb_demux_feed_t
*
dvbdmxfeed
)
dvb_feed_start_pid
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmx
->
priv
;
u16
*
pid
=
dvbdmx
->
pids
,
npids
[
5
];
int
i
;
...
...
@@ -3329,9 +3344,9 @@ dvb_feed_start_pid(dvb_demux_feed_t *dvbdmxfeed)
}
static
void
dvb_feed_stop_pid
(
dvb_demux_feed_t
*
dvbdmxfeed
)
dvb_feed_stop_pid
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmx
->
priv
;
u16
*
pid
=
dvbdmx
->
pids
,
npids
[
5
];
int
i
;
...
...
@@ -3365,9 +3380,9 @@ dvb_feed_stop_pid(dvb_demux_feed_t *dvbdmxfeed)
}
static
int
dvb_start_feed
(
dvb_demux_feed_t
*
dvbdmxfeed
)
dvb_start_feed
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmx
->
priv
;
if
(
!
dvbdmx
->
dmx
.
frontend
)
...
...
@@ -3425,9 +3440,9 @@ dvb_start_feed(dvb_demux_feed_t *dvbdmxfeed)
static
int
dvb_stop_feed
(
dvb_demux_feed_t
*
dvbdmxfeed
)
dvb_stop_feed
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdmx
->
priv
;
if
(
av7110
->
saa
->
card_type
>=
DVB_CARD_TT_BUDGET
)
...
...
@@ -3468,8 +3483,8 @@ dvb_stop_feed(dvb_demux_feed_t *dvbdmxfeed)
static
void
restart_feeds
(
av7110_t
*
av7110
)
{
dvb_demux_t
*
dvbdmx
=&
av7110
->
demux
;
dvb_demux_feed_t
*
feed
;
struct
dvb_demux
*
dvbdmx
=&
av7110
->
demux
;
struct
dvb_demux_feed
*
feed
;
int
mode
;
int
i
;
...
...
@@ -3660,7 +3675,7 @@ ci_ll_read(ring_buffer_t *cibuf, struct file *file, char *buf, size_t count, lof
static
int
dvb_ca_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
int
err
=
dvb_generic_open
(
inode
,
file
);
...
...
@@ -3673,7 +3688,7 @@ dvb_ca_open(struct inode *inode, struct file *file)
static
unsigned
int
dvb_ca_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
int
mask
=
0
;
...
...
@@ -3702,7 +3717,7 @@ static int
dvb_ca_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
long
arg
=
(
unsigned
long
)
parg
;
...
...
@@ -3716,7 +3731,7 @@ dvb_ca_ioctl(struct inode *inode, struct file *file,
case
CA_GET_CAP
:
{
ca_cap_t
cap
;
ca_cap
s
_t
cap
;
cap
.
slot_num
=
2
;
#ifdef NEW_CI
...
...
@@ -3788,7 +3803,7 @@ static ssize_t
dvb_ca_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
return
ci_ll_write
(
&
av7110
->
ci_wbuffer
,
file
,
buf
,
count
,
ppos
);
...
...
@@ -3797,7 +3812,7 @@ dvb_ca_write(struct file *file, const char *buf,
static
ssize_t
dvb_ca_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
return
ci_ll_read
(
&
av7110
->
ci_rbuffer
,
file
,
buf
,
count
,
ppos
);
...
...
@@ -3812,7 +3827,7 @@ dvb_ca_read(struct file *file, char *buf, size_t count, loff_t *ppos)
static
unsigned
int
dvb_video_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
int
mask
=
0
;
...
...
@@ -3834,7 +3849,7 @@ static ssize_t
dvb_video_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
if
(
av7110
->
videostate
.
stream_source
!=
VIDEO_SOURCE_MEMORY
)
...
...
@@ -3847,7 +3862,7 @@ static ssize_t
dvb_audio_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
if
(
av7110
->
audiostate
.
stream_source
!=
AUDIO_SOURCE_MEMORY
)
{
...
...
@@ -3876,7 +3891,7 @@ play_iframe(av7110_t *av7110, u8 *buf, unsigned int len, int nonblock)
for
(
i
=
0
;
i
<
n
;
i
++
)
dvb_play
(
av7110
,
buf
,
len
,
0
,
1
,
1
);
send_ipack_rest
(
&
av7110
->
ipack
[
1
]);
dvb_filter_ipack_flush
(
&
av7110
->
ipack
[
1
]);
}
...
...
@@ -3884,7 +3899,7 @@ static int
dvb_video_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
long
arg
=
(
unsigned
long
)
parg
;
int
ret
=
0
;
...
...
@@ -4041,7 +4056,7 @@ dvb_video_ioctl(struct inode *inode, struct file *file,
case
VIDEO_CLEAR_BUFFER
:
ring_buffer_flush
(
&
av7110
->
avout
);
reset_ipack
(
&
av7110
->
ipack
[
1
]);
dvb_filter_ipack_reset
(
&
av7110
->
ipack
[
1
]);
if
(
av7110
->
playing
==
RP_AV
)
{
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
...
...
@@ -4073,7 +4088,7 @@ static int
dvb_audio_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
unsigned
long
arg
=
(
unsigned
long
)
parg
;
int
ret
=
0
;
...
...
@@ -4164,7 +4179,7 @@ dvb_audio_ioctl(struct inode *inode, struct file *file,
case
AUDIO_CLEAR_BUFFER
:
ring_buffer_flush
(
&
av7110
->
aout
);
reset_ipack
(
&
av7110
->
ipack
[
0
]);
dvb_filter_ipack_reset
(
&
av7110
->
ipack
[
0
]);
if
(
av7110
->
playing
==
RP_AV
)
outcom
(
av7110
,
COMTYPE_REC_PLAY
,
__Play
,
2
,
AV_PES
,
0
);
...
...
@@ -4192,7 +4207,7 @@ static int
dvb_osd_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
#ifdef CONFIG_DVB_AV7110_OSD
...
...
@@ -4204,7 +4219,7 @@ dvb_osd_ioctl(struct inode *inode, struct file *file,
static
int
dvb_video_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
int
err
;
...
...
@@ -4220,7 +4235,7 @@ static int dvb_video_open(struct inode *inode, struct file *file)
static
int
dvb_video_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
AV_Stop
(
av7110
,
RP_VIDEO
);
...
...
@@ -4229,7 +4244,7 @@ static int dvb_video_release(struct inode *inode, struct file *file)
static
int
dvb_audio_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
int
err
=
dvb_generic_open
(
inode
,
file
);
...
...
@@ -4242,7 +4257,7 @@ static int dvb_audio_open(struct inode *inode, struct file *file)
static
int
dvb_audio_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
av7110_t
*
av7110
=
(
av7110_t
*
)
dvbdev
->
priv
;
AV_Stop
(
av7110
,
RP_AUDIO
);
...
...
@@ -4256,75 +4271,70 @@ static int dvb_audio_release(struct inode *inode, struct file *file)
******************************************************************************/
static
struct
file_operations
dvb_video_fops
=
{
owner:
THIS_MODULE
,
read:
0
,
write:
dvb_video_write
,
ioctl:
dvb_generic_ioctl
,
open:
dvb_video_open
,
release:
dvb_video_release
,
poll:
dvb_video_poll
,
.
owner
=
THIS_MODULE
,
.
write
=
dvb_video_write
,
.
ioctl
=
dvb_generic_ioctl
,
.
open
=
dvb_video_open
,
.
release
=
dvb_video_release
,
.
poll
=
dvb_video_poll
,
};
static
dvb_device_t
dvbdev_video
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_video_fops
,
kernel_ioctl:
dvb_video_ioctl
,
static
struct
dvb_device
dvbdev_video
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_video_fops
,
.
kernel_ioctl
=
dvb_video_ioctl
,
};
static
struct
file_operations
dvb_audio_fops
=
{
owner:
THIS_MODULE
,
read:
0
,
write:
dvb_audio_write
,
ioctl:
dvb_generic_ioctl
,
open:
dvb_audio_open
,
release:
dvb_audio_release
,
poll:
dvb_audio_poll
,
.
owner
=
THIS_MODULE
,
.
write
=
dvb_audio_write
,
.
ioctl
=
dvb_generic_ioctl
,
.
open
=
dvb_audio_open
,
.
release
=
dvb_audio_release
,
.
poll
=
dvb_audio_poll
,
};
static
dvb_device_t
dvbdev_audio
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_audio_fops
,
kernel_ioctl:
dvb_audio_ioctl
,
static
struct
dvb_device
dvbdev_audio
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_audio_fops
,
.
kernel_ioctl
=
dvb_audio_ioctl
,
};
static
struct
file_operations
dvb_ca_fops
=
{
owner:
THIS_MODULE
,
read:
dvb_ca_read
,
write:
dvb_ca_write
,
ioctl:
dvb_generic_ioctl
,
open:
dvb_ca_open
,
release:
dvb_generic_release
,
poll:
dvb_ca_poll
,
.
owner
=
THIS_MODULE
,
.
read
=
dvb_ca_read
,
.
write
=
dvb_ca_write
,
.
ioctl
=
dvb_generic_ioctl
,
.
open
=
dvb_ca_open
,
.
release
=
dvb_generic_release
,
.
poll
=
dvb_ca_poll
,
};
static
dvb_device_t
dvbdev_ca
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_ca_fops
,
kernel_ioctl:
dvb_ca_ioctl
,
static
struct
dvb_device
dvbdev_ca
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_ca_fops
,
.
kernel_ioctl
=
dvb_ca_ioctl
,
};
static
struct
file_operations
dvb_osd_fops
=
{
owner:
THIS_MODULE
,
read:
0
,
write:
0
,
ioctl:
dvb_generic_ioctl
,
open:
dvb_generic_open
,
release:
dvb_generic_release
,
poll:
0
,
.
owner
=
THIS_MODULE
,
.
ioctl
=
dvb_generic_ioctl
,
.
open
=
dvb_generic_open
,
.
release
=
dvb_generic_release
,
};
static
dvb_device_t
dvbdev_osd
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_osd_fops
,
kernel_ioctl:
dvb_osd_ioctl
,
static
struct
dvb_device
dvbdev_osd
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_osd_fops
,
.
kernel_ioctl
=
dvb_osd_ioctl
,
};
...
...
@@ -4359,7 +4369,7 @@ dvb_register(av7110_t *av7110)
{
int
ret
,
i
;
dmx_frontend_t
*
dvbfront
=&
av7110
->
hw_frontend
;
dvb_demux_t
*
dvbdemux
=&
av7110
->
demux
;
struct
dvb_demux
*
dvbdemux
=&
av7110
->
demux
;
if
(
av7110
->
registered
)
return
-
1
;
...
...
@@ -4414,7 +4424,7 @@ dvb_register(av7110_t *av7110)
DMX_SECTION_FILTERING
|
DMX_MEMORY_BASED_FILTERING
);
DvbDmxI
nit
(
&
av7110
->
demux
);
dvb_dmx_i
nit
(
&
av7110
->
demux
);
dvbfront
->
id
=
"hw_frontend"
;
...
...
@@ -4426,7 +4436,7 @@ dvb_register(av7110_t *av7110)
av7110
->
dmxdev
.
demux
=&
dvbdemux
->
dmx
;
av7110
->
dmxdev
.
capabilities
=
0
;
DmxDevI
nit
(
&
av7110
->
dmxdev
,
av7110
->
dvb_adapter
);
dvb_dmxdev_i
nit
(
&
av7110
->
dmxdev
,
av7110
->
dvb_adapter
);
}
if
(
av7110
->
saa
->
card_type
>=
DVB_CARD_TT_BUDGET
)
{
...
...
@@ -4443,7 +4453,7 @@ dvb_register(av7110_t *av7110)
DMX_SECTION_FILTERING
|
DMX_MEMORY_BASED_FILTERING
);
DvbDmxI
nit
(
&
av7110
->
demux
);
dvb_dmx_i
nit
(
&
av7110
->
demux
);
dvbfront
->
id
=
"hw_frontend"
;
dvbfront
->
vendor
=
"VLSI"
;
...
...
@@ -4454,7 +4464,7 @@ dvb_register(av7110_t *av7110)
av7110
->
dmxdev
.
demux
=&
dvbdemux
->
dmx
;
av7110
->
dmxdev
.
capabilities
=
0
;
DmxDevI
nit
(
&
av7110
->
dmxdev
,
av7110
->
dvb_adapter
);
dvb_dmxdev_i
nit
(
&
av7110
->
dmxdev
,
av7110
->
dvb_adapter
);
}
ret
=
dvbdemux
->
dmx
.
add_frontend
(
&
dvbdemux
->
dmx
,
...
...
@@ -4505,7 +4515,7 @@ dvb_register(av7110_t *av7110)
static
void
dvb_unregister
(
av7110_t
*
av7110
)
{
dvb_demux_t
*
dvbdemux
=&
av7110
->
demux
;
struct
dvb_demux
*
dvbdemux
=&
av7110
->
demux
;
if
(
!
av7110
->
registered
)
return
;
...
...
@@ -4516,8 +4526,8 @@ dvb_unregister(av7110_t *av7110)
dvbdemux
->
dmx
.
remove_frontend
(
&
dvbdemux
->
dmx
,
&
av7110
->
hw_frontend
);
dvbdemux
->
dmx
.
remove_frontend
(
&
dvbdemux
->
dmx
,
&
av7110
->
mem_frontend
);
DmxDevR
elease
(
&
av7110
->
dmxdev
);
DvbDmxR
elease
(
&
av7110
->
demux
);
dvb_dmxdev_r
elease
(
&
av7110
->
dmxdev
);
dvb_dmx_r
elease
(
&
av7110
->
demux
);
if
(
av7110
->
saa
->
card_type
==
DVB_CARD_TT_SIEMENS
)
dvb_remove_frontend_notifier
(
av7110
->
dvb_adapter
,
...
...
@@ -4584,9 +4594,9 @@ int av7110_attach (struct saa7146 *saa, void **av7110_ptr)
av7110
->
vidmode
=
VIDEO_MODE_PAL
;
init_ipack
(
&
av7110
->
ipack
[
0
],
IPACKS
,
play_audio_cb
);
dvb_filter_ipack_init
(
&
av7110
->
ipack
[
0
],
IPACKS
,
play_audio_cb
);
av7110
->
ipack
[
0
].
data
=
(
void
*
)
av7110
;
init_ipack
(
&
av7110
->
ipack
[
1
],
IPACKS
,
play_video_cb
);
dvb_filter_ipack_init
(
&
av7110
->
ipack
[
1
],
IPACKS
,
play_video_cb
);
av7110
->
ipack
[
1
].
data
=
(
void
*
)
av7110
;
...
...
@@ -4705,8 +4715,8 @@ int av7110_detach (struct saa7146 *saa, void** av7110_ptr)
saa7146_write
(
av7110
->
saa_mem
,
ISR
,(
MASK_19
|
MASK_03
));
ci_ll_release
(
&
av7110
->
ci_rbuffer
,
&
av7110
->
ci_wbuffer
);
free_ipack
(
&
av7110
->
ipack
[
0
]);
free_ipack
(
&
av7110
->
ipack
[
1
]);
dvb_filter_ipack_free
(
&
av7110
->
ipack
[
0
]);
dvb_filter_ipack_free
(
&
av7110
->
ipack
[
1
]);
vfree
(
av7110
->
iobuf
);
pci_free_consistent
(
av7110
->
saa
->
device
,
8192
,
av7110
->
debi_virt
,
av7110
->
debi_bus
);
...
...
drivers/media/dvb/av7110/av7110.h
View file @
888c9d64
...
...
@@ -479,7 +479,7 @@ typedef struct p2t_s {
u8
counter
;
long
int
pos
;
int
frags
;
dvb_demux_feed_t
*
feed
;
struct
dvb_demux_feed
*
feed
;
}
p2t_t
;
...
...
@@ -561,7 +561,7 @@ typedef struct av7110_s {
int
vidmode
;
dmxdev_t
dmxdev
;
dvb_demux_t
demux
;
struct
dvb_demux
demux
;
char
demux_id
[
16
];
dmx_frontend_t
hw_frontend
;
...
...
@@ -580,9 +580,9 @@ typedef struct av7110_s {
#define TRICK_FREEZE 3
struct
audio_status
audiostate
;
dvb_demux_filter_t
*
handle2filter
[
32
];
struct
dvb_demux_filter
*
handle2filter
[
32
];
p2t_t
p2t_filter
[
MAXFILT
];
pes2ts_t
p2t
[
2
];
dvb_filter_pes2ts_t
p2t
[
2
];
struct
ipack_s
ipack
[
2
];
u8
*
kbuf
[
2
];
...
...
@@ -621,11 +621,11 @@ typedef struct av7110_s {
ring_buffer_t
ci_wbuffer
;
dvb_adapter_t
*
dvb_adapter
;
dvb_device_t
*
video_dev
;
dvb_device_t
*
audio_dev
;
dvb_device_t
*
ca_dev
;
dvb_device_t
*
osd_dev
;
struct
dvb_adapter
*
dvb_adapter
;
struct
dvb_device
*
video_dev
;
struct
dvb_device
*
audio_dev
;
struct
dvb_device
*
ca_dev
;
struct
dvb_device
*
osd_dev
;
int
dsp_dev
;
}
av7110_t
;
...
...
drivers/media/dvb/av7110/saa7146.c
View file @
888c9d64
...
...
@@ -1399,7 +1399,7 @@ int i2c_reset(struct saa7146* saa)
/* if any error is still present, a fatal error has occured ... */
if
(
SAA7146_I2C_BBR
!=
(
status
=
i2c_status_check
(
saa
))
)
{
hprintk
(
"saa7146: i2c_reset: fatal error, status:0x%08x
\n
"
,
status
);
return
-
1
;
return
-
EIO
;
}
return
0
;
...
...
drivers/media/dvb/av7110/saa7146_core.c
View file @
888c9d64
...
...
@@ -33,8 +33,8 @@
#include "saa7146_core.h"
#include "saa7146_v4l.h"
#include "av7110.h"
#include "
../dvb-core/
compat.h"
#include "
../dvb-core/
dvb_i2c.h"
#include "compat.h"
#include "dvb_i2c.h"
/* insmod parameter: here you can specify the number of video-buffers
to be allocated. for simple capturing 2 buffers (double-buffering)
...
...
@@ -197,23 +197,23 @@ static
int
do_master_xfer
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
)
{
struct
saa7146
*
a
=
i2c
->
data
;
int
result
,
count
;
int
count
;
int
i
=
0
;
dprintk
(
KERN_ERR
"saa7146_core.o: master_xfer called, num:%d
\n
"
,
num
);
/* prepare the message(s), get number of u32s to transfer */
count
=
prepare
(
msgs
,
num
,
a
->
i2c
);
if
(
0
>
count
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: could not prepare i2c-message
\n
"
);
if
(
count
<
0
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: could not prepare i2c-message
\n
"
);
return
-
EIO
;
}
/* reset the i2c-device if necessary */
result
=
i2c_reset
(
a
);
if
(
0
>
result
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: could not reset i2c-bus
\n
"
);
return
result
;
if
(
i2c_reset
(
a
)
<
0
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: could not reset i2c-bus
\n
"
);
return
-
EIO
;
}
for
(
i
=
0
;
i
<
count
;
i
++
)
{
...
...
@@ -222,31 +222,17 @@ int do_master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
* we do not start the whole rps1-engine...
*/
result
=
i2c_write_out
(
a
,
&
a
->
i2c
[
i
],
SAA7146_I2C_TIMEOUT
);
if
(
0
!=
result
)
{
/* if address-error occured, don't retry */
if
(
result
==
-
EREMOTEIO
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: error in address phase
\n
"
);
return
result
;
}
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: error transferring, trying again
\n
"
);
break
;
}
if
(
i2c_write_out
(
a
,
&
a
->
i2c
[
i
],
SAA7146_I2C_TIMEOUT
)
<
0
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: "
"i2c error in address phase
\n
"
);
return
-
EREMOTEIO
;
}
/* see if an error occured & the last retry failed */
if
(
0
!=
result
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: could not transfer i2c-message
\n
"
);
return
-
EIO
;
}
/* if any things had to be read, get the results */
result
=
clean_up
(
msgs
,
num
,
a
->
i2c
);
if
(
0
>
result
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: master_xfer: could not cleanup
\n
"
);
if
(
clean_up
(
msgs
,
num
,
a
->
i2c
)
<
0
)
{
hprintk
(
KERN_ERR
"saa7146_core.o: i2c cleanup failed!
\n
"
);
return
-
EIO
;
}
...
...
@@ -259,13 +245,19 @@ int do_master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
static
int
master_xfer
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
)
{
struct
saa7146
*
saa
=
i2c
->
data
;
int
retries
=
SAA7146_I2C_RETRIES
;
int
ret
;
if
(
down_interruptible
(
&
saa
->
i2c_sem
))
return
-
ERESTARTSYS
;
do
{
ret
=
do_master_xfer
(
i2c
,
msgs
,
num
);
}
while
(
ret
!=
num
&&
retries
--
);
up
(
&
saa
->
i2c_sem
);
return
ret
;
}
...
...
@@ -273,6 +265,8 @@ int master_xfer (struct dvb_i2c_bus *i2c, struct i2c_msg msgs[], int num)
/* registering functions to load algorithms at runtime */
int
i2c_saa7146_add_bus
(
struct
saa7146
*
saa
)
{
init_MUTEX
(
&
saa
->
i2c_sem
);
/* enable i2c-port pins */
saa7146_write
(
saa
->
mem
,
MC1
,
(
MASK_08
|
MASK_24
));
...
...
@@ -389,9 +383,9 @@ static int saa7146_core_command (struct dvb_i2c_bus *i2c, unsigned int cmd, void
struct
saa7146_debi_transfer
*
dt
=
arg
;
printk
(
"saa7146_core.o: SAA7146_DEBI_TRANSFER
\n
"
);
printk
(
"saa7146_core.o: timeout:%d, swap:%d, slave16:%d, increment:%d, intel:%d, tien:%d
\n
"
,
dt
->
timeout
,
dt
->
swap
,
dt
->
slave16
,
dt
->
increment
,
dt
->
intel
,
dt
->
tien
);
printk
(
"saa7146_core.o: address:0x%04x, num_bytes:%d, direction:%d, mem:0x%08x
\n
"
,
dt
->
address
,
dt
->
address
,
dt
->
direction
,
dt
->
mem
);
d
printk
(
"saa7146_core.o: SAA7146_DEBI_TRANSFER
\n
"
);
d
printk
(
"saa7146_core.o: timeout:%d, swap:%d, slave16:%d, increment:%d, intel:%d, tien:%d
\n
"
,
dt
->
timeout
,
dt
->
swap
,
dt
->
slave16
,
dt
->
increment
,
dt
->
intel
,
dt
->
tien
);
d
printk
(
"saa7146_core.o: address:0x%04x, num_bytes:%d, direction:%d, mem:0x%08x
\n
"
,
dt
->
address
,
dt
->
address
,
dt
->
direction
,
dt
->
mem
);
debi_transfer
(
saa
,
dt
);
break
;
...
...
@@ -622,7 +616,7 @@ int configure_saa7146 (struct saa7146 *saa)
}
/* print status message */
printk
(
KERN_ERR
"saa7146_core.o: %s: bus:%d, rev:%d, mem:0x%08x.
\n
"
,
saa
->
name
,
saa
->
device
->
bus
->
number
,
saa
->
revision
,
(
unsigned
int
)
saa
->
mem
);
dprintk
(
"saa7146_core.o: %s: bus:%d, rev:%d, mem:0x%08x.
\n
"
,
saa
->
name
,
saa
->
device
->
bus
->
number
,
saa
->
revision
,
(
unsigned
int
)
saa
->
mem
);
/* enable bus-mastering */
pci_set_master
(
saa
->
device
);
...
...
@@ -827,7 +821,7 @@ static
int
__devinit
saa7146_init_one
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
{
struct
dvb_adapter
_s
*
adap
;
struct
dvb_adapter
*
adap
;
struct
saa7146
*
saa
;
int
card_type
;
struct
card_info
*
cinfo
=
(
struct
card_info
*
)
ent
->
driver_data
;
...
...
drivers/media/dvb/av7110/saa7146_core.h
View file @
888c9d64
#ifndef __SAA7146_CORE__
#define __SAA7146_CORE__
#include <asm/io.h>
/* definitions of u32 etc. */
#include "../dvb-core/dvbdev.h"
#if LINUX_VERSION_CODE < 0x020300
#define DECLARE_MUTEX(foo) struct semaphore foo = MUTEX
#define DECLARE_MUTEX_LOCKED(foo) struct semaphore foo = MUTEX_LOCKED
#define WAIT_QUEUE struct wait_queue*
#define init_waitqueue_head(wq) *(wq) = NULL;
#else
#define WAIT_QUEUE wait_queue_head_t
#endif
#include <asm/io.h>
#include <asm/semaphore.h>
#include "dvbdev.h"
/* maximum number of capture frames we support */
#define SAA7146_MAX_BUF 5
...
...
@@ -37,12 +31,13 @@ struct saa7146 {
char
name
[
32
];
/* give it a nice name */
struct
list_head
list_head
;
dvb_adapter_t
*
dvb_adapter
;
struct
dvb_i2c_bus
*
i2c_bus
;
struct
pci_dev
*
device
;
int
card_type
;
struct
dvb_adapter
*
dvb_adapter
;
struct
dvb_i2c_bus
*
i2c_bus
;
struct
semaphore
i2c_sem
;
void
*
data
[
SAA7146_MAX_EXTENSIONS
];
/* data hooks for extensions */
int
(
*
command
)
(
struct
dvb_i2c_bus
*
i
,
unsigned
int
cmd
,
void
*
arg
);
...
...
@@ -70,8 +65,8 @@ struct saa7146 {
int
grab_format
[
SAA7146_MAX_BUF
];
/* video format of grabs */
int
grab_port
[
SAA7146_MAX_BUF
];
/* video port for grab */
WAIT_QUEUE
rps0_wq
;
/* rps0 interrupt queue (=> capture) */
WAIT_QUEUE
rps1_wq
;
/* rps1 interrupt queue (=> i2c, ...) */
wait_queue_head_t
rps0_wq
;
/* rps0 interrupt queue (=> capture) */
wait_queue_head_t
rps1_wq
;
/* rps1 interrupt queue (=> i2c, ...) */
};
#define SAA7146_IRQ_RPS0
...
...
drivers/media/dvb/av7110/saa7146_v4l.c
View file @
888c9d64
...
...
@@ -320,7 +320,6 @@ static int saa7146_v4l_command(struct saa7146* saa, void *p, unsigned int cmd, v
/* set corresponding buffer to unused */
saa
->
frame_stat
[
i
]
=
GBUFFER_UNUSED
;
printk
(
"saa7146_v4l.o: SAA7146_V4L_CSYNC, frame %i done.
\n
"
,
i
);
break
;
}
...
...
drivers/media/dvb/dvb-core/dmxdev.c
View file @
888c9d64
...
...
@@ -24,6 +24,7 @@
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/videodev.h>
#include <asm/uaccess.h>
#include "dmxdev.h"
...
...
@@ -40,19 +41,19 @@ static int debug = 0;
#define dprintk if (debug) printk
inline
dmxdev_filter_t
*
DmxDevFile2F
ilter
(
struct
file
*
file
)
dvb_dmxdev_file_to_f
ilter
(
struct
file
*
file
)
{
return
(
dmxdev_filter_t
*
)
file
->
private_data
;
}
inline
dmxdev_dvr_t
*
DmxDevFile2DVR
(
dmxdev_t
*
dmxdev
,
struct
file
*
file
)
dvb_dmxdev_file_to_dvr
(
dmxdev_t
*
dmxdev
,
struct
file
*
file
)
{
return
(
dmxdev_dvr_t
*
)
file
->
private_data
;
}
static
inline
void
DmxDevBufferI
nit
(
dmxdev_buffer_t
*
buffer
)
dvb_dmxdev_buffer_i
nit
(
dmxdev_buffer_t
*
buffer
)
{
buffer
->
data
=
0
;
buffer
->
size
=
8192
;
...
...
@@ -63,7 +64,7 @@ DmxDevBufferInit(dmxdev_buffer_t *buffer)
}
static
inline
int
DmxDevBufferW
rite
(
dmxdev_buffer_t
*
buf
,
uint8_t
*
src
,
int
len
)
dvb_dmxdev_buffer_w
rite
(
dmxdev_buffer_t
*
buf
,
uint8_t
*
src
,
int
len
)
{
int
split
;
int
free
;
...
...
@@ -98,7 +99,7 @@ DmxDevBufferWrite(dmxdev_buffer_t *buf, uint8_t *src, int len)
}
static
ssize_t
DmxDevBufferR
ead
(
dmxdev_buffer_t
*
src
,
int
non_blocking
,
dvb_dmxdev_buffer_r
ead
(
dmxdev_buffer_t
*
src
,
int
non_blocking
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
unsigned
long
todo
=
count
;
...
...
@@ -108,6 +109,7 @@ DmxDevBufferRead(dmxdev_buffer_t *src, int non_blocking,
return
0
;
if
((
error
=
src
->
error
))
{
src
->
pwrite
=
src
->
pread
;
src
->
error
=
0
;
return
error
;
}
...
...
@@ -125,6 +127,7 @@ DmxDevBufferRead(dmxdev_buffer_t *src, int non_blocking,
return
count
-
todo
;
if
((
error
=
src
->
error
))
{
src
->
pwrite
=
src
->
pread
;
src
->
error
=
0
;
return
error
;
}
...
...
@@ -172,7 +175,7 @@ get_fe(dmx_demux_t *demux, int type)
}
static
inline
void
DmxDevDVRStateS
et
(
dmxdev_dvr_t
*
dmxdevdvr
,
int
state
)
dvb_dmxdev_dvr_state_s
et
(
dmxdev_dvr_t
*
dmxdevdvr
,
int
state
)
{
spin_lock_irq
(
&
dmxdevdvr
->
dev
->
lock
);
dmxdevdvr
->
state
=
state
;
...
...
@@ -181,7 +184,7 @@ DmxDevDVRStateSet(dmxdev_dvr_t *dmxdevdvr, int state)
static
int
dvb_dvr_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
dmx_frontend_t
*
front
;
...
...
@@ -198,7 +201,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
}
if
((
file
->
f_flags
&
O_ACCMODE
)
==
O_RDONLY
)
{
DmxDevBufferI
nit
(
&
dmxdev
->
dvr_buffer
);
dvb_dmxdev_buffer_i
nit
(
&
dmxdev
->
dvr_buffer
);
dmxdev
->
dvr_buffer
.
size
=
DVR_BUFFER_SIZE
;
dmxdev
->
dvr_buffer
.
data
=
vmalloc
(
DVR_BUFFER_SIZE
);
if
(
!
dmxdev
->
dvr_buffer
.
data
)
{
...
...
@@ -230,7 +233,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file)
static
int
dvb_dvr_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
if
(
down_interruptible
(
&
dmxdev
->
mutex
))
...
...
@@ -258,7 +261,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file)
static
ssize_t
dvb_dvr_write
(
struct
file
*
file
,
const
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
int
ret
;
...
...
@@ -276,12 +279,12 @@ dvb_dvr_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
static
ssize_t
dvb_dvr_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
int
ret
;
//down(&dmxdev->mutex);
ret
=
DmxDevBufferR
ead
(
&
dmxdev
->
dvr_buffer
,
ret
=
dvb_dmxdev_buffer_r
ead
(
&
dmxdev
->
dvr_buffer
,
file
->
f_flags
&
O_NONBLOCK
,
buf
,
count
,
ppos
);
//up(&dmxdev->mutex);
...
...
@@ -289,7 +292,7 @@ dvb_dvr_read(struct file *file, char *buf, size_t count, loff_t *ppos)
}
static
inline
void
DmxDevFilterStateS
et
(
dmxdev_filter_t
*
dmxdevfilter
,
int
state
)
dvb_dmxdev_filter_state_s
et
(
dmxdev_filter_t
*
dmxdevfilter
,
int
state
)
{
spin_lock_irq
(
&
dmxdevfilter
->
dev
->
lock
);
dmxdevfilter
->
state
=
state
;
...
...
@@ -297,7 +300,7 @@ DmxDevFilterStateSet(dmxdev_filter_t *dmxdevfilter, int state)
}
static
int
DmxDevSetBufferS
ize
(
dmxdev_filter_t
*
dmxdevfilter
,
unsigned
long
size
)
dvb_dmxdev_set_buffer_s
ize
(
dmxdev_filter_t
*
dmxdevfilter
,
unsigned
long
size
)
{
dmxdev_buffer_t
*
buf
=&
dmxdevfilter
->
buffer
;
void
*
mem
;
...
...
@@ -327,7 +330,7 @@ DmxDevSetBufferSize(dmxdev_filter_t *dmxdevfilter, unsigned long size)
}
static
void
DmxDevFilterT
imeout
(
unsigned
long
data
)
dvb_dmxdev_filter_t
imeout
(
unsigned
long
data
)
{
dmxdev_filter_t
*
dmxdevfilter
=
(
dmxdev_filter_t
*
)
data
;
...
...
@@ -339,13 +342,13 @@ DmxDevFilterTimeout(unsigned long data)
}
static
void
DmxDevFilterT
imer
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_filter_t
imer
(
dmxdev_filter_t
*
dmxdevfilter
)
{
struct
dmx_sct_filter_params
*
para
=&
dmxdevfilter
->
params
.
sec
;
del_timer
(
&
dmxdevfilter
->
timer
);
if
(
para
->
timeout
)
{
dmxdevfilter
->
timer
.
function
=
DmxDevFilterT
imeout
;
dmxdevfilter
->
timer
.
function
=
dvb_dmxdev_filter_t
imeout
;
dmxdevfilter
->
timer
.
data
=
(
unsigned
long
)
dmxdevfilter
;
dmxdevfilter
->
timer
.
expires
=
jiffies
+
1
+
(
HZ
/
2
+
HZ
*
para
->
timeout
)
/
1000
;
add_timer
(
&
dmxdevfilter
->
timer
);
...
...
@@ -353,7 +356,7 @@ DmxDevFilterTimer(dmxdev_filter_t *dmxdevfilter)
}
static
int
DmxDevSectionC
allback
(
u8
*
buffer1
,
size_t
buffer1_len
,
dvb_dmxdev_section_c
allback
(
u8
*
buffer1
,
size_t
buffer1_len
,
u8
*
buffer2
,
size_t
buffer2_len
,
dmx_section_filter_t
*
filter
,
dmx_success_t
success
)
...
...
@@ -375,9 +378,9 @@ DmxDevSectionCallback(u8 *buffer1, size_t buffer1_len,
buffer1
[
0
],
buffer1
[
1
],
buffer1
[
2
],
buffer1
[
3
],
buffer1
[
4
],
buffer1
[
5
]);
ret
=
DmxDevBufferW
rite
(
&
dmxdevfilter
->
buffer
,
buffer1
,
buffer1_len
);
ret
=
dvb_dmxdev_buffer_w
rite
(
&
dmxdevfilter
->
buffer
,
buffer1
,
buffer1_len
);
if
(
ret
==
buffer1_len
)
{
ret
=
DmxDevBufferW
rite
(
&
dmxdevfilter
->
buffer
,
buffer2
,
buffer2_len
);
ret
=
dvb_dmxdev_buffer_w
rite
(
&
dmxdevfilter
->
buffer
,
buffer2
,
buffer2_len
);
}
if
(
ret
<
0
)
{
dmxdevfilter
->
buffer
.
pwrite
=
dmxdevfilter
->
buffer
.
pread
;
...
...
@@ -391,7 +394,7 @@ DmxDevSectionCallback(u8 *buffer1, size_t buffer1_len,
}
static
int
DmxDevTSC
allback
(
u8
*
buffer1
,
size_t
buffer1_len
,
dvb_dmxdev_ts_c
allback
(
u8
*
buffer1
,
size_t
buffer1_len
,
u8
*
buffer2
,
size_t
buffer2_len
,
dmx_ts_feed_t
*
feed
,
dmx_success_t
success
)
...
...
@@ -415,9 +418,9 @@ DmxDevTSCallback(u8 *buffer1, size_t buffer1_len,
wake_up
(
&
buffer
->
queue
);
return
0
;
}
ret
=
DmxDevBufferW
rite
(
buffer
,
buffer1
,
buffer1_len
);
ret
=
dvb_dmxdev_buffer_w
rite
(
buffer
,
buffer1
,
buffer1_len
);
if
(
ret
==
buffer1_len
)
ret
=
DmxDevBufferW
rite
(
buffer
,
buffer2
,
buffer2_len
);
ret
=
dvb_dmxdev_buffer_w
rite
(
buffer
,
buffer2
,
buffer2_len
);
if
(
ret
<
0
)
{
buffer
->
pwrite
=
buffer
->
pread
;
buffer
->
error
=-
EOVERFLOW
;
...
...
@@ -431,9 +434,9 @@ DmxDevTSCallback(u8 *buffer1, size_t buffer1_len,
/* stop feed but only mark the specified filter as stopped (state set) */
static
int
DmxDevFeedS
top
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_feed_s
top
(
dmxdev_filter_t
*
dmxdevfilter
)
{
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
switch
(
dmxdevfilter
->
type
)
{
case
DMXDEV_TYPE_SEC
:
...
...
@@ -453,9 +456,9 @@ DmxDevFeedStop(dmxdev_filter_t *dmxdevfilter)
/* start feed associated with the specified filter */
static
int
DmxDevFeedS
tart
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_feed_s
tart
(
dmxdev_filter_t
*
dmxdevfilter
)
{
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_GO
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_GO
);
switch
(
dmxdevfilter
->
type
)
{
case
DMXDEV_TYPE_SEC
:
...
...
@@ -475,7 +478,7 @@ DmxDevFeedStart(dmxdev_filter_t *dmxdevfilter)
otherwise release the feed */
static
int
DmxDevFeedR
estart
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_feed_r
estart
(
dmxdev_filter_t
*
dmxdevfilter
)
{
int
i
;
dmxdev_t
*
dmxdev
=
dmxdevfilter
->
dev
;
...
...
@@ -485,7 +488,7 @@ DmxDevFeedRestart(dmxdev_filter_t *dmxdevfilter)
if
(
dmxdev
->
filter
[
i
].
state
>=
DMXDEV_STATE_GO
&&
dmxdev
->
filter
[
i
].
type
==
DMXDEV_TYPE_SEC
&&
dmxdev
->
filter
[
i
].
pid
==
pid
)
{
DmxDevFeedS
tart
(
&
dmxdev
->
filter
[
i
]);
dvb_dmxdev_feed_s
tart
(
&
dmxdev
->
filter
[
i
]);
return
0
;
}
...
...
@@ -497,7 +500,7 @@ DmxDevFeedRestart(dmxdev_filter_t *dmxdevfilter)
}
static
int
DmxDevFilterS
top
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_filter_s
top
(
dmxdev_filter_t
*
dmxdevfilter
)
{
if
(
dmxdevfilter
->
state
<
DMXDEV_STATE_GO
)
return
0
;
...
...
@@ -506,18 +509,18 @@ DmxDevFilterStop(dmxdev_filter_t *dmxdevfilter)
case
DMXDEV_TYPE_SEC
:
if
(
!
dmxdevfilter
->
feed
.
sec
)
break
;
DmxDevFeedS
top
(
dmxdevfilter
);
dvb_dmxdev_feed_s
top
(
dmxdevfilter
);
if
(
dmxdevfilter
->
filter
.
sec
)
dmxdevfilter
->
feed
.
sec
->
release_filter
(
dmxdevfilter
->
feed
.
sec
,
dmxdevfilter
->
filter
.
sec
);
DmxDevFeedR
estart
(
dmxdevfilter
);
dvb_dmxdev_feed_r
estart
(
dmxdevfilter
);
dmxdevfilter
->
feed
.
sec
=
0
;
break
;
case
DMXDEV_TYPE_PES
:
if
(
!
dmxdevfilter
->
feed
.
ts
)
break
;
DmxDevFeedS
top
(
dmxdevfilter
);
dvb_dmxdev_feed_s
top
(
dmxdevfilter
);
dmxdevfilter
->
dev
->
demux
->
release_ts_feed
(
dmxdevfilter
->
dev
->
demux
,
dmxdevfilter
->
feed
.
ts
);
...
...
@@ -533,19 +536,19 @@ DmxDevFilterStop(dmxdev_filter_t *dmxdevfilter)
}
static
inline
int
DmxDevFilterR
eset
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_filter_r
eset
(
dmxdev_filter_t
*
dmxdevfilter
)
{
if
(
dmxdevfilter
->
state
<
DMXDEV_STATE_SET
)
return
0
;
dmxdevfilter
->
type
=
DMXDEV_TYPE_NONE
;
dmxdevfilter
->
pid
=
0xffff
;
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_ALLOCATED
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_ALLOCATED
);
return
0
;
}
static
int
DmxDevFilterS
tart
(
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_filter_s
tart
(
dmxdev_filter_t
*
dmxdevfilter
)
{
dmxdev_t
*
dmxdev
=
dmxdevfilter
->
dev
;
void
*
mem
;
...
...
@@ -554,7 +557,7 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
if
(
dmxdevfilter
->
state
<
DMXDEV_STATE_SET
)
return
-
EINVAL
;
if
(
dmxdevfilter
->
state
>=
DMXDEV_STATE_GO
)
DmxDevFilterS
top
(
dmxdevfilter
);
dvb_dmxdev_filter_s
top
(
dmxdevfilter
);
mem
=
dmxdevfilter
->
buffer
.
data
;
if
(
!
mem
)
{
...
...
@@ -566,6 +569,8 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
return
-
ENOMEM
;
}
dmxdevfilter
->
buffer
.
pwrite
=
dmxdevfilter
->
buffer
.
pread
=
0
;
switch
(
dmxdevfilter
->
type
)
{
case
DMXDEV_TYPE_SEC
:
{
...
...
@@ -588,10 +593,9 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
/* if no feed found, try to allocate new one */
if
(
!*
secfeed
)
{
ret
=
dmxdev
->
demux
->
allocate_section_feed
(
dmxdev
->
demux
,
ret
=
dmxdev
->
demux
->
allocate_section_feed
(
dmxdev
->
demux
,
secfeed
,
DmxDevSectionC
allback
);
dvb_dmxdev_section_c
allback
);
if
(
ret
<
0
)
{
printk
(
"DVB (%s): could not alloc feed
\n
"
,
__FUNCTION__
);
...
...
@@ -604,18 +608,17 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
if
(
ret
<
0
)
{
printk
(
"DVB (%s): could not set feed
\n
"
,
__FUNCTION__
);
DmxDevFeedR
estart
(
dmxdevfilter
);
dvb_dmxdev_feed_r
estart
(
dmxdevfilter
);
return
ret
;
}
}
else
DmxDevFeedS
top
(
dmxdevfilter
);
dvb_dmxdev_feed_s
top
(
dmxdevfilter
);
ret
=
(
*
secfeed
)
->
allocate_filter
(
*
secfeed
,
secfilter
);
if
(
ret
<
0
)
{
DmxDevFeedRestart
(
dmxdevfilter
);
dmxdevfilter
->
feed
.
sec
->
start_filtering
(
*
secfeed
);
dvb_dmxdev_feed_restart
(
dmxdevfilter
);
dmxdevfilter
->
feed
.
sec
->
start_filtering
(
*
secfeed
);
dprintk
(
"could not get filter
\n
"
);
return
ret
;
}
...
...
@@ -636,15 +639,14 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
(
*
secfilter
)
->
filter_mask
[
2
]
=
0
;
dmxdevfilter
->
todo
=
0
;
dmxdevfilter
->
feed
.
sec
->
start_filtering
(
dmxdevfilter
->
feed
.
sec
);
DmxDevFilterTimer
(
dmxdevfilter
);
dmxdevfilter
->
feed
.
sec
->
start_filtering
(
dmxdevfilter
->
feed
.
sec
);
dvb_dmxdev_filter_timer
(
dmxdevfilter
);
break
;
}
case
DMXDEV_TYPE_PES
:
{
struct
timespec
timeout
=
{
0
};
struct
timespec
timeout
=
{
0
};
struct
dmx_pes_filter_params
*
para
=&
dmxdevfilter
->
params
.
pes
;
dmx_output_t
otype
;
int
ret
;
...
...
@@ -670,31 +672,29 @@ DmxDevFilterStart(dmxdev_filter_t *dmxdevfilter)
ret
=
dmxdev
->
demux
->
allocate_ts_feed
(
dmxdev
->
demux
,
tsfeed
,
DmxDevTSC
allback
);
dvb_dmxdev_ts_c
allback
);
if
(
ret
<
0
)
return
ret
;
(
*
tsfeed
)
->
priv
=
(
void
*
)
dmxdevfilter
;
ret
=
(
*
tsfeed
)
->
set
(
*
tsfeed
,
para
->
pid
,
ts_type
,
ts_pes
,
188
,
32768
,
0
,
timeout
);
if
(
ret
<
0
)
{
dmxdev
->
demux
->
release_ts_feed
(
dmxdev
->
demux
,
*
tsfeed
);
dmxdev
->
demux
->
release_ts_feed
(
dmxdev
->
demux
,
*
tsfeed
);
return
ret
;
}
dmxdevfilter
->
feed
.
ts
->
start_filtering
(
dmxdevfilter
->
feed
.
ts
);
dmxdevfilter
->
feed
.
ts
->
start_filtering
(
dmxdevfilter
->
feed
.
ts
);
break
;
}
default:
return
-
EINVAL
;
}
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_GO
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_GO
);
return
0
;
}
static
int
dvb_demux_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
int
i
;
dmxdev_filter_t
*
dmxdevfilter
;
...
...
@@ -714,9 +714,9 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
dmxdevfilter
->
dvbdev
=
dmxdev
->
dvbdev
;
file
->
private_data
=
dmxdevfilter
;
DmxDevBufferI
nit
(
&
dmxdevfilter
->
buffer
);
dvb_dmxdev_buffer_i
nit
(
&
dmxdevfilter
->
buffer
);
dmxdevfilter
->
type
=
DMXDEV_TYPE_NONE
;
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_ALLOCATED
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_ALLOCATED
);
dmxdevfilter
->
feed
.
ts
=
0
;
init_timer
(
&
dmxdevfilter
->
timer
);
...
...
@@ -725,13 +725,13 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
}
int
DmxDevFilterF
ree
(
dmxdev_t
*
dmxdev
,
dmxdev_filter_t
*
dmxdevfilter
)
dvb_dmxdev_filter_f
ree
(
dmxdev_t
*
dmxdev
,
dmxdev_filter_t
*
dmxdevfilter
)
{
if
(
down_interruptible
(
&
dmxdev
->
mutex
))
return
-
ERESTARTSYS
;
DmxDevFilterS
top
(
dmxdevfilter
);
DmxDevFilterR
eset
(
dmxdevfilter
);
dvb_dmxdev_filter_s
top
(
dmxdevfilter
);
dvb_dmxdev_filter_r
eset
(
dmxdevfilter
);
if
(
dmxdevfilter
->
buffer
.
data
)
{
void
*
mem
=
dmxdevfilter
->
buffer
.
data
;
...
...
@@ -741,7 +741,7 @@ DmxDevFilterFree(dmxdev_t *dmxdev, dmxdev_filter_t *dmxdevfilter)
spin_unlock_irq
(
&
dmxdev
->
lock
);
vfree
(
mem
);
}
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_FREE
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_FREE
);
wake_up
(
&
dmxdevfilter
->
buffer
.
queue
);
up
(
&
dmxdev
->
mutex
);
return
0
;
...
...
@@ -758,33 +758,33 @@ invert_mode(dmx_filter_t *filter)
static
int
DmxDevFilterS
et
(
dmxdev_t
*
dmxdev
,
dvb_dmxdev_filter_s
et
(
dmxdev_t
*
dmxdev
,
dmxdev_filter_t
*
dmxdevfilter
,
struct
dmx_sct_filter_params
*
params
)
{
dprintk
(
"function : %s
\n
"
,
__FUNCTION__
);
DmxDevFilterS
top
(
dmxdevfilter
);
dvb_dmxdev_filter_s
top
(
dmxdevfilter
);
dmxdevfilter
->
type
=
DMXDEV_TYPE_SEC
;
dmxdevfilter
->
pid
=
params
->
pid
;
memcpy
(
&
dmxdevfilter
->
params
.
sec
,
params
,
sizeof
(
struct
dmx_sct_filter_params
));
invert_mode
(
&
dmxdevfilter
->
params
.
sec
.
filter
);
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
if
(
params
->
flags
&
DMX_IMMEDIATE_START
)
return
DmxDevFilterS
tart
(
dmxdevfilter
);
return
dvb_dmxdev_filter_s
tart
(
dmxdevfilter
);
return
0
;
}
static
int
DmxDevPesFilterS
et
(
dmxdev_t
*
dmxdev
,
dvb_dmxdev_pes_filter_s
et
(
dmxdev_t
*
dmxdev
,
dmxdev_filter_t
*
dmxdevfilter
,
struct
dmx_pes_filter_params
*
params
)
{
DmxDevFilterS
top
(
dmxdevfilter
);
dvb_dmxdev_filter_s
top
(
dmxdevfilter
);
if
(
params
->
pes_type
>
DMX_PES_OTHER
||
params
->
pes_type
<
0
)
return
-
EINVAL
;
...
...
@@ -793,16 +793,16 @@ DmxDevPesFilterSet(dmxdev_t *dmxdev,
dmxdevfilter
->
pid
=
params
->
pid
;
memcpy
(
&
dmxdevfilter
->
params
,
params
,
sizeof
(
struct
dmx_pes_filter_params
));
DmxDevFilterStateS
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
dvb_dmxdev_filter_state_s
et
(
dmxdevfilter
,
DMXDEV_STATE_SET
);
if
(
params
->
flags
&
DMX_IMMEDIATE_START
)
return
DmxDevFilterS
tart
(
dmxdevfilter
);
return
dvb_dmxdev_filter_s
tart
(
dmxdevfilter
);
return
0
;
}
static
ssize_t
DmxDevReadS
ec
(
dmxdev_filter_t
*
dfil
,
struct
file
*
file
,
dvb_dmxdev_read_s
ec
(
dmxdev_filter_t
*
dfil
,
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
int
result
,
hcount
;
...
...
@@ -812,7 +812,7 @@ DmxDevReadSec(dmxdev_filter_t *dfil, struct file *file,
hcount
=
3
+
dfil
->
todo
;
if
(
hcount
>
count
)
hcount
=
count
;
result
=
DmxDevBufferR
ead
(
&
dfil
->
buffer
,
file
->
f_flags
&
O_NONBLOCK
,
result
=
dvb_dmxdev_buffer_r
ead
(
&
dfil
->
buffer
,
file
->
f_flags
&
O_NONBLOCK
,
buf
,
hcount
,
ppos
);
if
(
result
<
0
)
{
dfil
->
todo
=
0
;
...
...
@@ -832,7 +832,7 @@ DmxDevReadSec(dmxdev_filter_t *dfil, struct file *file,
}
if
(
count
>
dfil
->
todo
)
count
=
dfil
->
todo
;
result
=
DmxDevBufferR
ead
(
&
dfil
->
buffer
,
file
->
f_flags
&
O_NONBLOCK
,
result
=
dvb_dmxdev_buffer_r
ead
(
&
dfil
->
buffer
,
file
->
f_flags
&
O_NONBLOCK
,
buf
,
count
,
ppos
);
if
(
result
<
0
)
return
result
;
...
...
@@ -844,16 +844,16 @@ DmxDevReadSec(dmxdev_filter_t *dfil, struct file *file,
ssize_t
dvb_demux_read
(
struct
file
*
file
,
char
*
buf
,
size_t
count
,
loff_t
*
ppos
)
{
dmxdev_filter_t
*
dmxdevfilter
=
DmxDevFile2F
ilter
(
file
);
dmxdev_filter_t
*
dmxdevfilter
=
dvb_dmxdev_file_to_f
ilter
(
file
);
//dmxdev_t *dmxdev=dmxdevfilter->dev;
int
ret
=
0
;
// semaphore should not be necessary (I hope ...)
//down(&dmxdev->mutex);
if
(
dmxdevfilter
->
type
==
DMXDEV_TYPE_SEC
)
ret
=
DmxDevReadS
ec
(
dmxdevfilter
,
file
,
buf
,
count
,
ppos
);
ret
=
dvb_dmxdev_read_s
ec
(
dmxdevfilter
,
file
,
buf
,
count
,
ppos
);
else
ret
=
DmxDevBufferR
ead
(
&
dmxdevfilter
->
buffer
,
ret
=
dvb_dmxdev_buffer_r
ead
(
&
dmxdevfilter
->
buffer
,
file
->
f_flags
&
O_NONBLOCK
,
buf
,
count
,
ppos
);
//up(&dmxdev->mutex);
...
...
@@ -864,7 +864,7 @@ dvb_demux_read(struct file *file, char *buf, size_t count, loff_t *ppos)
static
int
dvb_demux_do_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dmxdev_filter_t
*
dmxdevfilter
=
DmxDevFile2F
ilter
(
file
);
dmxdev_filter_t
*
dmxdevfilter
=
dvb_dmxdev_file_to_f
ilter
(
file
);
dmxdev_t
*
dmxdev
=
dmxdevfilter
->
dev
;
unsigned
long
arg
=
(
unsigned
long
)
parg
;
int
ret
=
0
;
...
...
@@ -877,25 +877,25 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
if
(
dmxdevfilter
->
state
<
DMXDEV_STATE_SET
)
ret
=-
EINVAL
;
else
ret
=
DmxDevFilterS
tart
(
dmxdevfilter
);
ret
=
dvb_dmxdev_filter_s
tart
(
dmxdevfilter
);
break
;
case
DMX_STOP
:
ret
=
DmxDevFilterS
top
(
dmxdevfilter
);
ret
=
dvb_dmxdev_filter_s
top
(
dmxdevfilter
);
break
;
case
DMX_SET_FILTER
:
ret
=
DmxDevFilterS
et
(
dmxdev
,
dmxdevfilter
,
ret
=
dvb_dmxdev_filter_s
et
(
dmxdev
,
dmxdevfilter
,
(
struct
dmx_sct_filter_params
*
)
parg
);
break
;
case
DMX_SET_PES_FILTER
:
ret
=
DmxDevPesFilterS
et
(
dmxdev
,
dmxdevfilter
,
ret
=
dvb_dmxdev_pes_filter_s
et
(
dmxdev
,
dmxdevfilter
,
(
struct
dmx_pes_filter_params
*
)
parg
);
break
;
case
DMX_SET_BUFFER_SIZE
:
ret
=
DmxDevSetBufferS
ize
(
dmxdevfilter
,
arg
);
ret
=
dvb_dmxdev_set_buffer_s
ize
(
dmxdevfilter
,
arg
);
break
;
case
DMX_GET_EVENT
:
...
...
@@ -919,13 +919,13 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
static
int
dvb_demux_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
return
generic
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvb_demux_do_ioctl
);
return
video
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvb_demux_do_ioctl
);
}
static
unsigned
int
dvb_demux_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
dmxdev_filter_t
*
dmxdevfilter
=
DmxDevFile2F
ilter
(
file
);
dmxdev_filter_t
*
dmxdevfilter
=
dvb_dmxdev_file_to_f
ilter
(
file
);
if
(
!
dmxdevfilter
)
return
-
EINVAL
;
...
...
@@ -958,33 +958,32 @@ static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
static
int
dvb_demux_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dmxdev_filter_t
*
dmxdevfilter
=
DmxDevFile2F
ilter
(
file
);
dmxdev_filter_t
*
dmxdevfilter
=
dvb_dmxdev_file_to_f
ilter
(
file
);
dmxdev_t
*
dmxdev
=
dmxdevfilter
->
dev
;
return
DmxDevFilterF
ree
(
dmxdev
,
dmxdevfilter
);
return
dvb_dmxdev_filter_f
ree
(
dmxdev
,
dmxdevfilter
);
}
static
struct
file_operations
dvb_demux_fops
=
{
owner:
THIS_MODULE
,
read:
dvb_demux_read
,
write:
0
,
ioctl:
dvb_demux_ioctl
,
open:
dvb_demux_open
,
release:
dvb_demux_release
,
poll:
dvb_demux_poll
,
.
owner
=
THIS_MODULE
,
.
read
=
dvb_demux_read
,
.
ioctl
=
dvb_demux_ioctl
,
.
open
=
dvb_demux_open
,
.
release
=
dvb_demux_release
,
.
poll
=
dvb_demux_poll
,
};
static
dvb_device_t
dvbdev_demux
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_demux_fops
static
struct
dvb_device
dvbdev_demux
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_demux_fops
};
static
int
dvb_dvr_do_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
int
ret
=
0
;
...
...
@@ -1008,13 +1007,13 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
static
int
dvb_dvr_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
return
generic
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvb_dvr_do_ioctl
);
return
video
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvb_dvr_do_ioctl
);
}
static
unsigned
int
dvb_dvr_poll
(
struct
file
*
file
,
poll_table
*
wait
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dmxdev_t
*
dmxdev
=
(
dmxdev_t
*
)
dvbdev
->
priv
;
dprintk
(
"function : %s
\n
"
,
__FUNCTION__
);
...
...
@@ -1040,24 +1039,24 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
}
static
struct
file_operations
dvb_dvr_fops
=
{
owner:
THIS_MODULE
,
read:
dvb_dvr_read
,
write:
dvb_dvr_write
,
ioctl:
dvb_dvr_ioctl
,
open:
dvb_dvr_open
,
release:
dvb_dvr_release
,
poll:
dvb_dvr_poll
,
.
owner
=
THIS_MODULE
,
.
read
=
dvb_dvr_read
,
.
write
=
dvb_dvr_write
,
.
ioctl
=
dvb_dvr_ioctl
,
.
open
=
dvb_dvr_open
,
.
release
=
dvb_dvr_release
,
.
poll
=
dvb_dvr_poll
,
};
static
dvb_device_t
dvbdev_dvr
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_dvr_fops
static
struct
dvb_device
dvbdev_dvr
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_dvr_fops
};
int
DmxDevInit
(
dmxdev_t
*
dmxdev
,
dvb_adapter_t
*
dvb_adapter
)
dvb_dmxdev_init
(
dmxdev_t
*
dmxdev
,
struct
dvb_adapter
*
dvb_adapter
)
{
int
i
;
...
...
@@ -1079,22 +1078,22 @@ DmxDevInit(dmxdev_t *dmxdev, dvb_adapter_t *dvb_adapter)
for
(
i
=
0
;
i
<
dmxdev
->
filternum
;
i
++
)
{
dmxdev
->
filter
[
i
].
dev
=
dmxdev
;
dmxdev
->
filter
[
i
].
buffer
.
data
=
0
;
DmxDevFilterStateS
et
(
&
dmxdev
->
filter
[
i
],
DMXDEV_STATE_FREE
);
dvb_dmxdev_filter_state_s
et
(
&
dmxdev
->
filter
[
i
],
DMXDEV_STATE_FREE
);
dmxdev
->
dvr
[
i
].
dev
=
dmxdev
;
dmxdev
->
dvr
[
i
].
buffer
.
data
=
0
;
DmxDevFilterStateS
et
(
&
dmxdev
->
filter
[
i
],
DMXDEV_STATE_FREE
);
DmxDevDVRStateS
et
(
&
dmxdev
->
dvr
[
i
],
DMXDEV_STATE_FREE
);
dvb_dmxdev_filter_state_s
et
(
&
dmxdev
->
filter
[
i
],
DMXDEV_STATE_FREE
);
dvb_dmxdev_dvr_state_s
et
(
&
dmxdev
->
dvr
[
i
],
DMXDEV_STATE_FREE
);
}
dvb_register_device
(
dvb_adapter
,
&
dmxdev
->
dvbdev
,
&
dvbdev_demux
,
dmxdev
,
DVB_DEVICE_DEMUX
);
dvb_register_device
(
dvb_adapter
,
&
dmxdev
->
dvr_dvbdev
,
&
dvbdev_dvr
,
dmxdev
,
DVB_DEVICE_DVR
);
DmxDevBufferI
nit
(
&
dmxdev
->
dvr_buffer
);
dvb_dmxdev_buffer_i
nit
(
&
dmxdev
->
dvr_buffer
);
MOD_INC_USE_COUNT
;
return
0
;
}
void
DmxDevR
elease
(
dmxdev_t
*
dmxdev
)
dvb_dmxdev_r
elease
(
dmxdev_t
*
dmxdev
)
{
dvb_unregister_device
(
dmxdev
->
dvbdev
);
dvb_unregister_device
(
dmxdev
->
dvr_dvbdev
);
...
...
drivers/media/dvb/dvb-core/dmxdev.h
View file @
888c9d64
...
...
@@ -64,7 +64,7 @@ typedef struct dmxdev_buffer_s {
typedef
struct
dmxdev_filter_s
{
dvb_device_t
*
dvbdev
;
struct
dvb_device
*
dvbdev
;
union
{
dmx_section_filter_t
*
sec
;
...
...
@@ -102,8 +102,8 @@ typedef struct dmxdev_dvr_s {
typedef
struct
dmxdev_s
{
dvb_device_t
*
dvbdev
;
dvb_device_t
*
dvr_dvbdev
;
struct
dvb_device
*
dvbdev
;
struct
dvb_device
*
dvr_dvbdev
;
dmxdev_filter_t
*
filter
;
dmxdev_dvr_t
*
dvr
;
...
...
@@ -122,7 +122,7 @@ typedef struct dmxdev_s {
}
dmxdev_t
;
int
DmxDevInit
(
dmxdev_t
*
dmxdev
,
dvb_adapter_t
*
);
void
DmxDevR
elease
(
dmxdev_t
*
dmxdev
);
int
dvb_dmxdev_init
(
dmxdev_t
*
dmxdev
,
struct
dvb_adapter
*
);
void
dvb_dmxdev_r
elease
(
dmxdev_t
*
dmxdev
);
#endif
/* _DMXDEV_H_ */
drivers/media/dvb/dvb-core/dvb_demux.c
View file @
888c9d64
...
...
@@ -182,7 +182,7 @@ void dvb_set_crc32(u8 *data, int length)
******************************************************************************/
static
inline
int
DvbDmxSWFilterPayload
(
dvb_demux_feed_t
*
dvbdmxfeed
,
const
u8
*
buf
)
dvb_dmx_swfilter_payload
(
struct
dvb_demux_feed
*
dvbdmxfeed
,
const
u8
*
buf
)
{
int
p
,
count
;
//int ccok;
...
...
@@ -208,8 +208,8 @@ DvbDmxSWFilterPayload(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
static
int
DvbDmxSWFilterSectionFilter
(
dvb_demux_feed_t
*
dvbdmxfeed
,
dvb_demux_filter_t
*
f
)
dvb_dmx_swfilter_sectionfilter
(
struct
dvb_demux_feed
*
dvbdmxfeed
,
struct
dvb_demux_filter
*
f
)
{
dmx_section_filter_t
*
filter
=&
f
->
filter
;
int
i
;
...
...
@@ -229,10 +229,10 @@ DvbDmxSWFilterSectionFilter(dvb_demux_feed_t *dvbdmxfeed,
}
static
inline
int
DvbDmxSWFilterSectionFeed
(
dvb_demux_feed_t
*
dvbdmxfeed
)
dvb_dmx_swfilter_section_feed
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
u8
*
buf
=
dvbdmxfeed
->
secbuf
;
dvb_demux_filter_t
*
f
;
struct
dvb_demux_filter
*
f
;
if
(
dvbdmxfeed
->
secbufp
!=
dvbdmxfeed
->
seclen
)
return
-
1
;
...
...
@@ -241,7 +241,7 @@ DvbDmxSWFilterSectionFeed(dvb_demux_feed_t *dvbdmxfeed)
if
(
!
(
f
=
dvbdmxfeed
->
filter
))
return
0
;
do
if
(
DvbDmxSWFilterSectionF
ilter
(
dvbdmxfeed
,
f
)
<
0
)
if
(
dvb_dmx_swfilter_sectionf
ilter
(
dvbdmxfeed
,
f
)
<
0
)
return
-
1
;
while
((
f
=
f
->
next
)
&&
dvbdmxfeed
->
feed
.
sec
.
is_filtering
);
...
...
@@ -251,7 +251,7 @@ DvbDmxSWFilterSectionFeed(dvb_demux_feed_t *dvbdmxfeed)
}
static
inline
int
DvbDmxSWFilterSectionPacket
(
dvb_demux_feed_t
*
dvbdmxfeed
,
const
u8
*
buf
)
dvb_dmx_swfilter_section_packet
(
struct
dvb_demux_feed
*
dvbdmxfeed
,
const
u8
*
buf
)
{
int
p
,
count
;
int
ccok
,
rest
;
...
...
@@ -286,7 +286,7 @@ DvbDmxSWFilterSectionPacket(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
memcpy
(
dvbdmxfeed
->
secbuf
+
dvbdmxfeed
->
secbufp
,
buf
+
p
+
1
,
buf
[
p
]);
dvbdmxfeed
->
secbufp
+=
buf
[
p
];
DvbDmxSWFilterSectionF
eed
(
dvbdmxfeed
);
dvb_dmx_swfilter_section_f
eed
(
dvbdmxfeed
);
}
}
p
+=
buf
[
p
]
+
1
;
// skip rest of last section
...
...
@@ -301,7 +301,7 @@ DvbDmxSWFilterSectionPacket(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
dvbdmxfeed
->
secbufp
=
dvbdmxfeed
->
seclen
;
p
+=
dvbdmxfeed
->
seclen
;
count
=
188
-
p
;
DvbDmxSWFilterSectionF
eed
(
dvbdmxfeed
);
dvb_dmx_swfilter_section_f
eed
(
dvbdmxfeed
);
// filling bytes until packet end?
if
(
count
&&
buf
[
p
]
==
0xff
)
...
...
@@ -337,7 +337,7 @@ DvbDmxSWFilterSectionPacket(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
if
(
rest
<=
count
)
{
// section completed in this TS packet
memcpy
(
dvbdmxfeed
->
secbuf
+
dvbdmxfeed
->
secbufp
,
buf
+
p
,
rest
);
dvbdmxfeed
->
secbufp
+=
rest
;
DvbDmxSWFilterSectionF
eed
(
dvbdmxfeed
);
dvb_dmx_swfilter_section_f
eed
(
dvbdmxfeed
);
}
else
{
// section continues in following ts packet
memcpy
(
dvbdmxfeed
->
secbuf
+
dvbdmxfeed
->
secbufp
,
buf
+
p
,
count
);
dvbdmxfeed
->
secbufp
+=
count
;
...
...
@@ -346,7 +346,7 @@ DvbDmxSWFilterSectionPacket(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
}
static
inline
void
DvbDmxSWFilterPacketType
(
dvb_demux_feed_t
*
dvbdmxfeed
,
const
u8
*
buf
)
dvb_dmx_swfilter_packet_type
(
struct
dvb_demux_feed
*
dvbdmxfeed
,
const
u8
*
buf
)
{
switch
(
dvbdmxfeed
->
type
)
{
case
DMX_TYPE_TS
:
...
...
@@ -354,7 +354,7 @@ DvbDmxSWFilterPacketType(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
break
;
if
(
dvbdmxfeed
->
ts_type
&
TS_PACKET
)
{
if
(
dvbdmxfeed
->
ts_type
&
TS_PAYLOAD_ONLY
)
DvbDmxSWFilterP
ayload
(
dvbdmxfeed
,
buf
);
dvb_dmx_swfilter_p
ayload
(
dvbdmxfeed
,
buf
);
else
dvbdmxfeed
->
cb
.
ts
((
u8
*
)
buf
,
188
,
0
,
0
,
&
dvbdmxfeed
->
feed
.
ts
,
DMX_OK
);
...
...
@@ -368,7 +368,7 @@ DvbDmxSWFilterPacketType(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
case
DMX_TYPE_SEC
:
if
(
!
dvbdmxfeed
->
feed
.
sec
.
is_filtering
)
break
;
if
(
DvbDmxSWFilterSectionP
acket
(
dvbdmxfeed
,
buf
)
<
0
)
if
(
dvb_dmx_swfilter_section_p
acket
(
dvbdmxfeed
,
buf
)
<
0
)
dvbdmxfeed
->
seclen
=
dvbdmxfeed
->
secbufp
=
0
;
break
;
...
...
@@ -377,27 +377,27 @@ DvbDmxSWFilterPacketType(dvb_demux_feed_t *dvbdmxfeed, const u8 *buf)
}
}
void
inline
DvbDmxSWFilterPacket
(
dvb_demux_t
*
dvbdmx
,
const
u8
*
buf
)
void
dvb_dmx_swfilter_packet
(
struct
dvb_demux
*
dvbdmx
,
const
u8
*
buf
)
{
dvb_demux_feed_t
*
dvbdmxfeed
;
struct
dvb_demux_feed
*
dvbdmxfeed
;
if
(
!
(
dvbdmxfeed
=
dvbdmx
->
pid2feed
[
ts_pid
(
buf
)]))
return
;
DvbDmxSWFilterPacketT
ype
(
dvbdmxfeed
,
buf
);
dvb_dmx_swfilter_packet_t
ype
(
dvbdmxfeed
,
buf
);
}
void
DvbDmxSWFilterPackets
(
dvb_demux_t
*
dvbdmx
,
const
u8
*
buf
,
int
count
)
dvb_dmx_swfilter_packets
(
struct
dvb_demux
*
dvbdmx
,
const
u8
*
buf
,
int
count
)
{
dvb_demux_feed_t
*
dvbdmxfeed
;
struct
dvb_demux_feed
*
dvbdmxfeed
;
spin_lock
(
&
dvbdmx
->
lock
);
if
((
dvbdmxfeed
=
dvbdmx
->
pid2feed
[
0x2000
]))
dvbdmxfeed
->
cb
.
ts
((
u8
*
)
buf
,
count
*
188
,
0
,
0
,
&
dvbdmxfeed
->
feed
.
ts
,
DMX_OK
);
while
(
count
)
{
DvbDmxSWFilterP
acket
(
dvbdmx
,
buf
);
dvb_dmx_swfilter_p
acket
(
dvbdmx
,
buf
);
count
--
;
buf
+=
188
;
}
...
...
@@ -405,7 +405,7 @@ DvbDmxSWFilterPackets(dvb_demux_t *dvbdmx, const u8 *buf, int count)
}
static
inline
void
DvbDmxSWFilter
(
dvb_demux_t
*
dvbdmx
,
const
u8
*
buf
,
size_t
count
)
dvb_dmx_swfilter
(
struct
dvb_demux
*
dvbdmx
,
const
u8
*
buf
,
size_t
count
)
{
int
p
=
0
,
i
,
j
;
...
...
@@ -416,7 +416,7 @@ DvbDmxSWFilter(dvb_demux_t *dvbdmx, const u8 *buf, size_t count)
return
;
}
memcpy
(
&
dvbdmx
->
tsbuf
[
i
],
buf
,
j
);
DvbDmxSWFilterP
acket
(
dvbdmx
,
dvbdmx
->
tsbuf
);
dvb_dmx_swfilter_p
acket
(
dvbdmx
,
dvbdmx
->
tsbuf
);
dvbdmx
->
tsbufp
=
0
;
p
+=
j
;
}
...
...
@@ -424,7 +424,7 @@ DvbDmxSWFilter(dvb_demux_t *dvbdmx, const u8 *buf, size_t count)
while
(
p
<
count
)
{
if
(
buf
[
p
]
==
0x47
)
{
if
(
count
-
p
>=
188
)
{
DvbDmxSWFilterP
acket
(
dvbdmx
,
buf
+
p
);
dvb_dmx_swfilter_p
acket
(
dvbdmx
,
buf
+
p
);
p
+=
188
;
}
else
{
i
=
count
-
p
;
...
...
@@ -444,8 +444,8 @@ DvbDmxSWFilter(dvb_demux_t *dvbdmx, const u8 *buf, size_t count)
******************************************************************************
******************************************************************************/
static
dvb_demux_filter_t
*
DvbDmxFilterAlloc
(
dvb_demux_t
*
dvbdmx
)
static
struct
dvb_demux_filter
*
dvb_dmx_filter_alloc
(
struct
dvb_demux
*
dvbdmx
)
{
int
i
;
...
...
@@ -458,8 +458,8 @@ DvbDmxFilterAlloc(dvb_demux_t *dvbdmx)
return
&
dvbdmx
->
filter
[
i
];
}
static
dvb_demux_feed_t
*
DvbDmxFeedAlloc
(
dvb_demux_t
*
dvbdmx
)
static
struct
dvb_demux_feed
*
dvb_dmx_feed_alloc
(
struct
dvb_demux
*
dvbdmx
)
{
int
i
;
...
...
@@ -478,10 +478,10 @@ DvbDmxFeedAlloc(dvb_demux_t *dvbdmx)
******************************************************************************/
static
int
dmx_pid_set
(
u16
pid
,
dvb_demux_feed_t
*
dvbdmxfeed
)
dmx_pid_set
(
u16
pid
,
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
dvb_demux_feed_t
**
pid2feed
=
dvbdmx
->
pid2feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
**
pid2feed
=
dvbdmx
->
pid2feed
;
if
(
pid
>
DMX_MAX_PID
)
return
-
EINVAL
;
...
...
@@ -510,8 +510,8 @@ dmx_ts_feed_set(struct dmx_ts_feed_s* feed,
struct
timespec
timeout
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
int
ret
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
...
...
@@ -576,8 +576,8 @@ dmx_ts_feed_set(struct dmx_ts_feed_s* feed,
static
int
dmx_ts_feed_start_filtering
(
struct
dmx_ts_feed_s
*
feed
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
int
ret
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
...
...
@@ -608,8 +608,8 @@ dmx_ts_feed_start_filtering(struct dmx_ts_feed_s* feed)
static
int
dmx_ts_feed_stop_filtering
(
struct
dmx_ts_feed_s
*
feed
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
int
ret
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
...
...
@@ -637,13 +637,13 @@ static int dvbdmx_allocate_ts_feed(dmx_demux_t *demux,
dmx_ts_feed_t
**
feed
,
dmx_ts_cb
callback
)
{
dvb_demux_t
*
dvbdmx
=
(
dvb_demux_t
*
)
demux
;
dvb_demux_feed_t
*
dvbdmxfeed
;
struct
dvb_demux
*
dvbdmx
=
(
struct
dvb_demux
*
)
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
return
-
ERESTARTSYS
;
if
(
!
(
dvbdmxfeed
=
DvbDmxFeedA
lloc
(
dvbdmx
)))
{
if
(
!
(
dvbdmxfeed
=
dvb_dmx_feed_a
lloc
(
dvbdmx
)))
{
up
(
&
dvbdmx
->
mutex
);
return
-
EBUSY
;
}
...
...
@@ -663,7 +663,7 @@ static int dvbdmx_allocate_ts_feed(dmx_demux_t *demux,
(
*
feed
)
->
stop_filtering
=
dmx_ts_feed_stop_filtering
;
if
(
!
(
dvbdmxfeed
->
filter
=
DvbDmxFilterA
lloc
(
dvbdmx
)))
{
if
(
!
(
dvbdmxfeed
->
filter
=
dvb_dmx_filter_a
lloc
(
dvbdmx
)))
{
dvbdmxfeed
->
state
=
DMX_STATE_FREE
;
up
(
&
dvbdmx
->
mutex
);
return
-
EBUSY
;
...
...
@@ -679,8 +679,8 @@ static int dvbdmx_allocate_ts_feed(dmx_demux_t *demux,
static
int
dvbdmx_release_ts_feed
(
dmx_demux_t
*
demux
,
dmx_ts_feed_t
*
feed
)
{
dvb_demux_t
*
dvbdmx
=
(
dvb_demux_t
*
)
demux
;
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
(
struct
dvb_demux
*
)
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
return
-
ERESTARTSYS
;
...
...
@@ -715,14 +715,14 @@ static int
dmx_section_feed_allocate_filter
(
struct
dmx_section_feed_s
*
feed
,
dmx_section_filter_t
**
filter
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdemux
=
dvbdmxfeed
->
demux
;
dvb_demux_filter_t
*
dvbdmxfilter
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdemux
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_filter
*
dvbdmxfilter
;
if
(
down_interruptible
(
&
dvbdemux
->
mutex
))
return
-
ERESTARTSYS
;
dvbdmxfilter
=
DvbDmxFilterA
lloc
(
dvbdemux
);
dvbdmxfilter
=
dvb_dmx_filter_a
lloc
(
dvbdemux
);
if
(
!
dvbdmxfilter
)
{
up
(
&
dvbdemux
->
mutex
);
return
-
ENOSPC
;
...
...
@@ -747,8 +747,8 @@ dmx_section_feed_set(struct dmx_section_feed_s* feed,
u16
pid
,
size_t
circular_buffer_size
,
int
descramble
,
int
check_crc
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
if
(
pid
>
0x1fff
)
return
-
EINVAL
;
...
...
@@ -789,11 +789,11 @@ dmx_section_feed_set(struct dmx_section_feed_s* feed,
return
0
;
}
static
void
prepare_secfilters
(
dvb_demux_feed_t
*
dvbdmxfeed
)
static
void
prepare_secfilters
(
struct
dvb_demux_feed
*
dvbdmxfeed
)
{
int
i
;
dmx_section_filter_t
*
sf
;
dvb_demux_filter_t
*
f
;
struct
dvb_demux_filter
*
f
;
u8
mask
,
mode
,
doneq
;
if
(
!
(
f
=
dvbdmxfeed
->
filter
))
...
...
@@ -815,8 +815,8 @@ static void prepare_secfilters(dvb_demux_feed_t *dvbdmxfeed)
static
int
dmx_section_feed_start_filtering
(
dmx_section_feed_t
*
feed
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
int
ret
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
...
...
@@ -854,8 +854,8 @@ dmx_section_feed_start_filtering(dmx_section_feed_t *feed)
static
int
dmx_section_feed_stop_filtering
(
struct
dmx_section_feed_s
*
feed
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
int
ret
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
...
...
@@ -878,9 +878,9 @@ static int
dmx_section_feed_release_filter
(
dmx_section_feed_t
*
feed
,
dmx_section_filter_t
*
filter
)
{
dvb_demux_filter_t
*
dvbdmxfilter
=
(
dvb_demux_filter_t
*
)
filter
,
*
f
;
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
dvbdmxfeed
->
demux
;
struct
dvb_demux_filter
*
dvbdmxfilter
=
(
struct
dvb_demux_filter
*
)
filter
,
*
f
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
dvbdmxfeed
->
demux
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
return
-
ERESTARTSYS
;
...
...
@@ -911,13 +911,13 @@ static int dvbdmx_allocate_section_feed(dmx_demux_t *demux,
dmx_section_feed_t
**
feed
,
dmx_section_cb
callback
)
{
dvb_demux_t
*
dvbdmx
=
(
dvb_demux_t
*
)
demux
;
dvb_demux_feed_t
*
dvbdmxfeed
;
struct
dvb_demux
*
dvbdmx
=
(
struct
dvb_demux
*
)
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
return
-
ERESTARTSYS
;
if
(
!
(
dvbdmxfeed
=
DvbDmxFeedA
lloc
(
dvbdmx
)))
{
if
(
!
(
dvbdmxfeed
=
dvb_dmx_feed_a
lloc
(
dvbdmx
)))
{
up
(
&
dvbdmx
->
mutex
);
return
-
EBUSY
;
}
...
...
@@ -946,8 +946,8 @@ static int dvbdmx_allocate_section_feed(dmx_demux_t *demux,
static
int
dvbdmx_release_section_feed
(
dmx_demux_t
*
demux
,
dmx_section_feed_t
*
feed
)
{
dvb_demux_feed_t
*
dvbdmxfeed
=
(
dvb_demux_feed_t
*
)
feed
;
dvb_demux_t
*
dvbdmx
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux_feed
*
dvbdmxfeed
=
(
struct
dvb_demux_feed
*
)
feed
;
struct
dvb_demux
*
dvbdmx
=
(
struct
dvb_demux
*
)
demux
;
if
(
down_interruptible
(
&
dvbdmx
->
mutex
))
return
-
ERESTARTSYS
;
...
...
@@ -977,7 +977,7 @@ static int dvbdmx_release_section_feed(dmx_demux_t *demux,
static
int
dvbdmx_open
(
dmx_demux_t
*
demux
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
(
dvbdemux
->
users
>=
MAX_DVB_DEMUX_USERS
)
return
-
EUSERS
;
...
...
@@ -987,7 +987,7 @@ static int dvbdmx_open(dmx_demux_t *demux)
static
int
dvbdmx_close
(
struct
dmx_demux_s
*
demux
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
(
dvbdemux
->
users
==
0
)
return
-
ENODEV
;
...
...
@@ -998,7 +998,7 @@ static int dvbdmx_close(struct dmx_demux_s *demux)
static
int
dvbdmx_write
(
dmx_demux_t
*
demux
,
const
char
*
buf
,
size_t
count
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
((
!
demux
->
frontend
)
||
(
demux
->
frontend
->
source
!=
DMX_MEMORY_FE
))
...
...
@@ -1007,7 +1007,7 @@ static int dvbdmx_write(dmx_demux_t *demux, const char *buf, size_t count)
if
(
down_interruptible
(
&
dvbdemux
->
mutex
))
return
-
ERESTARTSYS
;
DvbDmxSWF
ilter
(
dvbdemux
,
buf
,
count
);
dvb_dmx_swf
ilter
(
dvbdemux
,
buf
,
count
);
up
(
&
dvbdemux
->
mutex
);
return
count
;
}
...
...
@@ -1016,7 +1016,7 @@ static int dvbdmx_write(dmx_demux_t *demux, const char *buf, size_t count)
static
int
dvbdmx_add_frontend
(
dmx_demux_t
*
demux
,
dmx_frontend_t
*
frontend
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
struct
list_head
*
pos
,
*
head
=&
dvbdemux
->
frontend_list
;
if
(
!
(
frontend
->
id
&&
frontend
->
vendor
&&
frontend
->
model
))
...
...
@@ -1035,7 +1035,7 @@ static int
dvbdmx_remove_frontend
(
dmx_demux_t
*
demux
,
dmx_frontend_t
*
frontend
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
struct
list_head
*
pos
,
*
n
,
*
head
=&
dvbdemux
->
frontend_list
;
list_for_each_safe
(
pos
,
n
,
head
)
...
...
@@ -1052,7 +1052,7 @@ dvbdmx_remove_frontend(dmx_demux_t *demux,
static
struct
list_head
*
dvbdmx_get_frontends
(
dmx_demux_t
*
demux
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
(
list_empty
(
&
dvbdemux
->
frontend_list
))
return
NULL
;
...
...
@@ -1062,7 +1062,7 @@ dvbdmx_get_frontends(dmx_demux_t *demux)
static
int
dvbdmx_connect_frontend
(
dmx_demux_t
*
demux
,
dmx_frontend_t
*
frontend
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
(
demux
->
frontend
)
return
-
EINVAL
;
...
...
@@ -1077,7 +1077,7 @@ static int dvbdmx_connect_frontend(dmx_demux_t *demux,
static
int
dvbdmx_disconnect_frontend
(
dmx_demux_t
*
demux
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
if
(
down_interruptible
(
&
dvbdemux
->
mutex
))
return
-
ERESTARTSYS
;
...
...
@@ -1089,24 +1089,24 @@ static int dvbdmx_disconnect_frontend(dmx_demux_t *demux)
static
int
dvbdmx_get_pes_pids
(
dmx_demux_t
*
demux
,
u16
*
pids
)
{
dvb_demux_t
*
dvbdemux
=
(
dvb_demux_t
*
)
demux
;
struct
dvb_demux
*
dvbdemux
=
(
struct
dvb_demux
*
)
demux
;
memcpy
(
pids
,
dvbdemux
->
pids
,
5
*
sizeof
(
u16
));
return
0
;
}
int
DvbDmxInit
(
dvb_demux_t
*
dvbdemux
)
dvb_dmx_init
(
struct
dvb_demux
*
dvbdemux
)
{
int
i
;
dmx_demux_t
*
dmx
=&
dvbdemux
->
dmx
;
dvbdemux
->
users
=
0
;
dvbdemux
->
filter
=
vmalloc
(
dvbdemux
->
filternum
*
sizeof
(
dvb_demux_filter_t
));
dvbdemux
->
filter
=
vmalloc
(
dvbdemux
->
filternum
*
sizeof
(
struct
dvb_demux_filter
));
if
(
!
dvbdemux
->
filter
)
return
-
ENOMEM
;
dvbdemux
->
feed
=
vmalloc
(
dvbdemux
->
feednum
*
sizeof
(
dvb_demux_feed_t
));
dvbdemux
->
feed
=
vmalloc
(
dvbdemux
->
feednum
*
sizeof
(
struct
dvb_demux_feed
));
if
(
!
dvbdemux
->
feed
)
{
vfree
(
dvbdemux
->
filter
);
return
-
ENOMEM
;
...
...
@@ -1125,7 +1125,7 @@ DvbDmxInit(dvb_demux_t *dvbdemux)
dvbdemux
->
pids
[
i
]
=
0xffff
;
}
dvbdemux
->
playing
=
dvbdemux
->
recording
=
0
;
memset
(
dvbdemux
->
pid2feed
,
0
,
(
DMX_MAX_PID
+
1
)
*
sizeof
(
dvb_demux_feed_t
*
));
memset
(
dvbdemux
->
pid2feed
,
0
,
(
DMX_MAX_PID
+
1
)
*
sizeof
(
struct
dvb_demux_feed
*
));
dvbdemux
->
tsbufp
=
0
;
dmx
->
frontend
=
0
;
...
...
@@ -1159,7 +1159,7 @@ DvbDmxInit(dvb_demux_t *dvbdemux)
}
int
DvbDmxRelease
(
dvb_demux_t
*
dvbdemux
)
dvb_dmx_release
(
struct
dvb_demux
*
dvbdemux
)
{
dmx_demux_t
*
dmx
=&
dvbdemux
->
dmx
;
...
...
drivers/media/dvb/dvb-core/dvb_demux.h
View file @
888c9d64
...
...
@@ -39,14 +39,14 @@
#define DVB_DEMUX_MASK_MAX 18
typedef
struct
dvb_demux_filter_s
{
struct
dvb_demux_filter
{
dmx_section_filter_t
filter
;
u8
maskandmode
[
DMX_MAX_FILTER_SIZE
];
u8
maskandnotmode
[
DMX_MAX_FILTER_SIZE
];
int
doneq
;
struct
dvb_demux_filter
_s
*
next
;
struct
dvb_demux_feed
_s
*
feed
;
struct
dvb_demux_filter
*
next
;
struct
dvb_demux_feed
*
feed
;
int
index
;
int
state
;
int
type
;
...
...
@@ -56,11 +56,10 @@ typedef struct dvb_demux_filter_s {
u16
hw_handle
;
struct
timer_list
timer
;
int
ts_state
;
};
//u16 pid; //to be removed
}
dvb_demux_filter_t
;
typedef
struct
dvb_demux_feed_s
{
struct
dvb_demux_feed
{
union
{
dmx_ts_feed_t
ts
;
dmx_section_feed_t
sec
;
...
...
@@ -71,7 +70,7 @@ typedef struct dvb_demux_feed_s {
dmx_section_cb
sec
;
}
cb
;
struct
dvb_demux
_s
*
demux
;
struct
dvb_demux
*
demux
;
int
type
;
int
state
;
u16
pid
;
...
...
@@ -81,7 +80,7 @@ typedef struct dvb_demux_feed_s {
int
check_crc
;
struct
timespec
timeout
;
dvb_demux_filter_t
*
filter
;
struct
dvb_demux_filter
*
filter
;
int
cb_length
;
int
ts_type
;
...
...
@@ -93,42 +92,43 @@ typedef struct dvb_demux_feed_s {
int
cc
;
u16
peslen
;
}
dvb_demux_feed_t
;
};
typedef
struct
dvb_demux_s
{
struct
dvb_demux
{
dmx_demux_t
dmx
;
void
*
priv
;
int
filternum
;
int
feednum
;
int
(
*
start_feed
)(
dvb_demux_feed_t
*
);
int
(
*
stop_feed
)(
dvb_demux_feed_t
*
);
int
(
*
write_to_decoder
)(
dvb_demux_feed_t
*
,
u8
*
,
size_t
);
int
(
*
start_feed
)(
struct
dvb_demux_feed
*
);
int
(
*
stop_feed
)(
struct
dvb_demux_feed
*
);
int
(
*
write_to_decoder
)(
struct
dvb_demux_feed
*
,
u8
*
,
size_t
);
int
users
;
#define MAX_DVB_DEMUX_USERS 10
dvb_demux_filter_t
*
filter
;
dvb_demux_feed_t
*
feed
;
struct
dvb_demux_filter
*
filter
;
struct
dvb_demux_feed
*
feed
;
struct
list_head
frontend_list
;
dvb_demux_feed_t
*
pesfilter
[
DMX_TS_PES_OTHER
];
struct
dvb_demux_feed
*
pesfilter
[
DMX_TS_PES_OTHER
];
u16
pids
[
DMX_TS_PES_OTHER
];
int
playing
;
int
recording
;
#define DMX_MAX_PID 0x2000
dvb_demux_feed_t
*
pid2feed
[
DMX_MAX_PID
+
1
];
struct
dvb_demux_feed
*
pid2feed
[
DMX_MAX_PID
+
1
];
u8
tsbuf
[
188
];
int
tsbufp
;
struct
semaphore
mutex
;
spinlock_t
lock
;
}
dvb_demux_t
;
};
int
DvbDmxInit
(
dvb_demux_t
*
dvbdemux
);
int
DvbDmxRelease
(
dvb_demux_t
*
dvbdemux
);
void
DvbDmxSWFilterPackets
(
dvb_demux_t
*
dvbdmx
,
const
u8
*
buf
,
int
count
);
int
dvb_dmx_init
(
struct
dvb_demux
*
dvbdemux
);
int
dvb_dmx_release
(
struct
dvb_demux
*
dvbdemux
);
void
dvb_dmx_swfilter_packet
(
struct
dvb_demux
*
dvbdmx
,
const
u8
*
buf
);
void
dvb_dmx_swfilter_packets
(
struct
dvb_demux
*
dvbdmx
,
const
u8
*
buf
,
int
count
);
#endif
/* _DVB_DEMUX_H_ */
drivers/media/dvb/dvb-core/dvb_filter.c
View file @
888c9d64
...
...
@@ -24,939 +24,978 @@ uint32_t ac3_frames[3][32] =
void
pes2ts_init
(
pes2ts_t
*
p2ts
,
unsigned
short
pid
,
pes2ts_cb_t
*
cb
,
void
*
priv
)
#if 0
static
void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
void (*pes_write)(u8 *buf, int count, void *data),
void *priv)
{
unsigned
char
*
buf
=
p2ts
->
buf
;
buf
[
0
]
=
0x47
;
buf
[
1
]
=
(
pid
>>
8
);
buf
[
2
]
=
pid
&
0xff
;
p2ts
->
cc
=
0
;
p2ts
->
cb
=
cb
;
p2ts
->
priv
=
priv
;
dvb_filter_ipack_init(pa, IPACKS, pes_write);
dvb_filter_ipack_init(pv, IPACKS, pes_write);
pa->pid = pida;
pv->pid = pidv;
pa->data = priv;
pv->data = priv;
}
#endif
int
pes2ts
(
pes2ts_t
*
p2ts
,
unsigned
char
*
pes
,
int
len
)
#if 0
static
void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
{
unsigned
char
*
buf
=
p2ts
->
buf
;
int
ret
=
0
,
rest
;
//len=6+((pes[4]<<8)|pes[5]);
u8 off = 0;
buf
[
1
]
|=
0x40
;
while
(
len
>=
184
)
{
buf
[
3
]
=
0x10
|
((
p2ts
->
cc
++
)
&
0x0f
);
memcpy
(
buf
+
4
,
pes
,
184
);
if
((
ret
=
p2ts
->
cb
(
p2ts
->
priv
,
buf
)))
return
ret
;
len
-=
184
;
pes
+=
184
;
buf
[
1
]
&=~
0x40
;
}
if
(
!
len
)
return
0
;
buf
[
3
]
=
0x30
|
((
p2ts
->
cc
++
)
&
0x0f
);
rest
=
183
-
len
;
if
(
rest
)
{
buf
[
5
]
=
0x00
;
if
(
rest
-
1
)
memset
(
buf
+
6
,
0xff
,
rest
-
1
);
if (!buf || !p ){
printk("NULL POINTER IDIOT\n");
return;
}
buf
[
4
]
=
rest
;
memcpy
(
buf
+
5
+
rest
,
pes
,
len
);
return
p2ts
->
cb
(
p2ts
->
priv
,
buf
);
}
void
reset_ipack
(
ipack
*
p
)
{
if (buf[1]&PAY_START) {
if (p->plength == MMAX_PLENGTH-6 && p->found>6){
p->plength = p->found-6;
p->found = 0;
p
->
cid
=
0
;
p
->
plength
=
0
;
p
->
flag1
=
0
;
p
->
flag2
=
0
;
p
->
hlength
=
0
;
p
->
mpeg
=
0
;
p
->
check
=
0
;
p
->
which
=
0
;
p
->
done
=
0
;
p
->
count
=
0
;
}
void
init_ipack
(
ipack
*
p
,
int
size
,
void
(
*
func
)(
u8
*
buf
,
int
size
,
void
*
priv
))
{
if
(
!
(
p
->
buf
=
vmalloc
(
size
*
sizeof
(
u8
)))
){
printk
(
"Couldn't allocate memory for ipack
\n
"
);
send_ipack(p);
dvb_filter_ipack_reset(p);
}
p
->
size
=
size
;
p
->
func
=
func
;
p
->
repack_subids
=
0
;
reset_ipack
(
p
);
}
void
free_ipack
(
ipack
*
p
)
{
if
(
p
->
buf
)
vfree
(
p
->
buf
);
}
if (buf[3] & ADAPT_FIELD) { // adaptation field?
off = buf[4] + 1;
if (off+4 > 187) return;
}
dvb_filter_instant_repack(buf+4+off, TS_SIZE-4-off, p);
}
#endif
void
send_ipack
(
ipack
*
p
)
#if 0
/* needs 5 byte input, returns picture coding type*/
static
int read_picture_header(uint8_t *headr, mpg_picture *pic, int field, int pr)
{
int
off
;
AudioInfo
ai
;
int
ac3_off
=
0
;
int
streamid
=
0
;
int
nframes
=
0
;
int
f
=
0
;
switch
(
p
->
mpeg
){
case
2
:
if
(
p
->
count
<
10
)
return
;
p
->
buf
[
3
]
=
p
->
cid
;
p
->
buf
[
4
]
=
(
u8
)(((
p
->
count
-
6
)
&
0xFF00
)
>>
8
);
p
->
buf
[
5
]
=
(
u8
)((
p
->
count
-
6
)
&
0x00FF
);
if
(
p
->
repack_subids
&&
p
->
cid
==
PRIVATE_STREAM1
){
uint8_t pct;
off
=
9
+
p
->
buf
[
8
];
streamid
=
p
->
buf
[
off
];
if
((
streamid
&
0xF8
)
==
0x80
){
ai
.
off
=
0
;
ac3_off
=
((
p
->
buf
[
off
+
2
]
<<
8
)
|
p
->
buf
[
off
+
3
]);
if
(
ac3_off
<
p
->
count
)
f
=
get_ac3info
(
p
->
buf
+
off
+
3
+
ac3_off
,
p
->
count
-
ac3_off
,
&
ai
,
0
);
if
(
!
f
){
nframes
=
(
p
->
count
-
off
-
3
-
ac3_off
)
/
ai
.
framesize
+
1
;
p
->
buf
[
off
+
2
]
=
(
ac3_off
>>
8
)
&
0xFF
;
p
->
buf
[
off
+
3
]
=
(
ac3_off
)
&
0xFF
;
p
->
buf
[
off
+
1
]
=
nframes
;
if (pr) printk( "Pic header: ");
pic->temporal_reference[field] = (( headr[0] << 2 ) |
(headr[1] & 0x03) )& 0x03ff;
if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]);
ac3_off
+=
nframes
*
ai
.
framesize
-
p
->
count
;
}
pct = ( headr[1] >> 2 ) & 0x07;
pic->picture_coding_type[field] = pct;
if (pr) {
switch(pct){
case I_FRAME:
printk( " I-FRAME");
break;
case B_FRAME:
printk( " B-FRAME");
break;
case P_FRAME:
printk( " P-FRAME");
break;
}
}
p
->
func
(
p
->
buf
,
p
->
count
,
p
->
data
);
p
->
buf
[
6
]
=
0x80
;
p
->
buf
[
7
]
=
0x00
;
p
->
buf
[
8
]
=
0x00
;
p
->
count
=
9
;
if
(
p
->
repack_subids
&&
p
->
cid
==
PRIVATE_STREAM1
&&
(
streamid
&
0xF8
)
==
0x80
){
p
->
count
+=
4
;
p
->
buf
[
9
]
=
streamid
;
p
->
buf
[
10
]
=
(
ac3_off
>>
8
)
&
0xFF
;
p
->
buf
[
11
]
=
(
ac3_off
)
&
0xFF
;
p
->
buf
[
12
]
=
0
;
}
break
;
case
1
:
if
(
p
->
count
<
8
)
return
;
p
->
buf
[
3
]
=
p
->
cid
;
pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) |
( (headr[3] & 0x1F) << 11) ) & 0xffff;
p
->
buf
[
4
]
=
(
u8
)(((
p
->
count
-
6
)
&
0xFF00
)
>>
8
);
p
->
buf
[
5
]
=
(
u8
)((
p
->
count
-
6
)
&
0x00FF
);
p
->
func
(
p
->
buf
,
p
->
count
,
p
->
data
);
if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay);
p
->
buf
[
6
]
=
0x0F
;
p
->
count
=
7
;
break
;
pic->picture_header_parameter = ( headr[3] & 0xe0 ) |
((headr[4] & 0x80) >> 3);
if ( pct == B_FRAME ){
pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f;
}
}
if (pr) printk( " pic head param: 0x%x",
pic->picture_header_parameter);
void
send_ipack_rest
(
ipack
*
p
)
{
if
(
p
->
plength
!=
MMAX_PLENGTH
-
6
||
p
->
found
<=
6
)
return
;
p
->
plength
=
p
->
found
-
6
;
p
->
found
=
0
;
send_ipack
(
p
);
reset_ipack
(
p
);
return pct;
}
#endif
static
void
write_ipack
(
ipack
*
p
,
u8
*
data
,
int
count
)
#if 0
/* needs 4 byte input */
static
int read_gop_header(uint8_t *headr, mpg_picture *pic, int pr)
{
u8
headr
[
3
]
=
{
0x00
,
0x00
,
0x01
}
;
if (pr) printk("GOP header: ");
if
(
p
->
count
<
6
){
memcpy
(
p
->
buf
,
headr
,
3
);
p
->
count
=
6
;
pic->time_code = (( headr[0] << 17 ) | ( headr[1] << 9) |
( headr[2] << 1 ) | (headr[3] &0x01)) & 0x1ffffff;
if (pr) printk(" time: %d:%d.%d ", (headr[0]>>2)& 0x1F,
((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F),
((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F));
if ( ( headr[3] & 0x40 ) != 0 ){
pic->closed_gop = 1;
} else {
pic->closed_gop = 0;
}
if (pr) printk("closed: %d", pic->closed_gop);
if
(
p
->
count
+
count
<
p
->
size
){
memcpy
(
p
->
buf
+
p
->
count
,
data
,
count
);
p
->
count
+=
count
;
if ( ( headr[3] & 0x20 ) != 0 ){
pic->broken_link = 1;
} else {
int
rest
=
p
->
size
-
p
->
count
;
memcpy
(
p
->
buf
+
p
->
count
,
data
,
rest
);
p
->
count
+=
rest
;
send_ipack
(
p
);
if
(
count
-
rest
>
0
)
write_ipack
(
p
,
data
+
rest
,
count
-
rest
);
pic->broken_link = 0;
}
if (pr) printk(" broken: %d\n", pic->broken_link);
return 0;
}
#endif
int
instant_repack
(
u8
*
buf
,
int
count
,
ipack
*
p
)
#if 0
/* needs 8 byte input */
static
int read_sequence_header(uint8_t *headr, VideoInfo *vi, int pr)
{
int
l
;
int
c
=
0
;
int sw
;
int
form = -1
;
while
(
c
<
count
&&
(
p
->
mpeg
==
0
||
(
p
->
mpeg
==
1
&&
p
->
found
<
7
)
||
(
p
->
mpeg
==
2
&&
p
->
found
<
9
))
&&
(
p
->
found
<
5
||
!
p
->
done
)){
switch
(
p
->
found
){
case
0
:
if (pr) printk("Reading sequence header\n");
vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]);
sw = (int)((headr[3]&0xF0) >> 4) ;
switch( sw ){
case 1:
if
(
buf
[
c
]
==
0x00
)
p
->
found
++
;
else
p
->
found
=
0
;
c
++
;
if (pr)
printk("Videostream: ASPECT: 1:1")
;
vi->aspect_ratio = 100;
break;
case 2:
if
(
buf
[
c
]
==
0x01
)
p
->
found
++
;
else
if
(
buf
[
c
]
==
0
)
{
p
->
found
=
2
;
}
else
p
->
found
=
0
;
c
++
;
if (pr)
printk("Videostream: ASPECT: 4:3");
vi->aspect_ratio = 133;
break;
case 3:
p
->
cid
=
0
;
switch
(
buf
[
c
]){
case
PROG_STREAM_MAP
:
case
PRIVATE_STREAM2
:
case
PROG_STREAM_DIR
:
case
ECM_STREAM
:
case
EMM_STREAM
:
case
PADDING_STREAM
:
case
DSM_CC_STREAM
:
case
ISO13522_STREAM
:
p
->
done
=
1
;
case
PRIVATE_STREAM1
:
case
VIDEO_STREAM_S
...
VIDEO_STREAM_E
:
case
AUDIO_STREAM_S
...
AUDIO_STREAM_E
:
p
->
found
++
;
p
->
cid
=
buf
[
c
];
c
++
;
if (pr)
printk("Videostream: ASPECT: 16:9");
vi->aspect_ratio = 177;
break;
default:
p
->
found
=
0
;
case 4:
if (pr)
printk("Videostream: ASPECT: 2.21:1");
vi->aspect_ratio = 221;
break;
}
case 5 ... 15:
if (pr)
printk("Videostream: ASPECT: reserved");
vi->aspect_ratio = 0;
break;
case
4
:
if
(
count
-
c
>
1
){
p
->
plen
[
0
]
=
buf
[
c
];
c
++
;
p
->
plen
[
1
]
=
buf
[
c
];
c
++
;
p
->
found
+=
2
;
p
->
plength
=
(
p
->
plen
[
0
]
<<
8
)
|
p
->
plen
[
1
];
}
else
{
p
->
plen
[
0
]
=
buf
[
c
];
p
->
found
++
;
return
count
;
default:
vi->aspect_ratio = 0;
return -1;
}
if (pr)
printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size);
sw = (int)(headr[3]&0x0F);
switch ( sw ) {
case 1:
if (pr)
printk(" FRate: 23.976 fps");
vi->framerate = 23976;
form = -1;
break;
case 2:
if (pr)
printk(" FRate: 24 fps");
vi->framerate = 24000;
form = -1;
break;
case 3:
if (pr)
printk(" FRate: 25 fps");
vi->framerate = 25000;
form = VIDEO_MODE_PAL;
break;
case 4:
if (pr)
printk(" FRate: 29.97 fps");
vi->framerate = 29970;
form = VIDEO_MODE_NTSC;
break;
case 5:
p
->
plen
[
1
]
=
buf
[
c
];
c
++
;
p
->
found
++
;
p
->
plength
=
(
p
->
plen
[
0
]
<<
8
)
|
p
->
plen
[
1
]
;
if (pr)
printk(" FRate: 30 fps")
;
vi->framerate = 30000
;
form = VIDEO_MODE_NTSC
;
break;
case 6:
if
(
!
p
->
done
){
p
->
flag1
=
buf
[
c
];
c
++
;
p
->
found
++
;
if
(
(
p
->
flag1
&
0xC0
)
==
0x80
)
p
->
mpeg
=
2
;
else
{
p
->
hlength
=
0
;
p
->
which
=
0
;
p
->
mpeg
=
1
;
p
->
flag2
=
0
;
}
}
if (pr)
printk(" FRate: 50 fps");
vi->framerate = 50000;
form = VIDEO_MODE_PAL;
break;
case 7:
if
(
!
p
->
done
&&
p
->
mpeg
==
2
)
{
p
->
flag2
=
buf
[
c
];
c
++
;
p
->
found
++
;
}
if (pr)
printk(" FRate: 60 fps");
vi->framerate = 60000;
form = VIDEO_MODE_NTSC;
break;
case
8
:
if
(
!
p
->
done
&&
p
->
mpeg
==
2
)
{
p
->
hlength
=
buf
[
c
];
c
++
;
p
->
found
++
;
}
break
;
default:
vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03);
break
;
}
vi->vbv_buffer_size
= (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5);
if (pr){
printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000);
printk(" vbvbuffer %d",16*1024*(vi->vbv_buffer_size));
printk("\n");
}
if
(
c
==
count
)
return
count
;
vi->video_format = form
;
if
(
!
p
->
plength
)
p
->
plength
=
MMAX_PLENGTH
-
6
;
return 0;
}
#endif
if
(
p
->
done
||
((
p
->
mpeg
==
2
&&
p
->
found
>=
9
)
||
(
p
->
mpeg
==
1
&&
p
->
found
>=
7
))
){
switch
(
p
->
cid
){
case
AUDIO_STREAM_S
...
AUDIO_STREAM_E
:
case
VIDEO_STREAM_S
...
VIDEO_STREAM_E
:
case
PRIVATE_STREAM1
:
#if 0
static
int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr)
{
uint8_t *headr;
int found = 0;
int c = 0;
if
(
p
->
mpeg
==
2
&&
p
->
found
==
9
)
{
write_ipack
(
p
,
&
p
->
flag1
,
1
);
write_ipack
(
p
,
&
p
->
flag2
,
1
);
write_ipack
(
p
,
&
p
->
hlength
,
1
);
while (found < 4 && c+4 < count){
uint8_t *b;
b = mbuf+c;
if ( b[0] == 0x00 && b[1] == 0x00 && b[2] == 0x01
&& b[3] == 0xb3) found = 4;
else {
c++;
}
}
if
(
p
->
mpeg
==
1
&&
p
->
found
==
7
)
write_ipack
(
p
,
&
p
->
flag1
,
1
);
if (! found) return -1;
c += 4;
if (c+12 >= count) return -1;
headr = mbuf+c;
if (read_sequence_header(headr, vi, pr) < 0) return -1;
vi->off = c-4;
return 0;
}
#endif
if
(
p
->
mpeg
==
2
&&
(
p
->
flag2
&
PTS_ONLY
)
&&
p
->
found
<
14
)
{
while
(
c
<
count
&&
p
->
found
<
14
)
{
p
->
pts
[
p
->
found
-
9
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
#if 0
static
int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr)
{
uint8_t *headr;
int found = 0;
int c = 0;
int fr = 0;
while (found < 2 && c < count){
uint8_t b[2];
memcpy( b, mbuf+c, 2);
if ( b[0] == 0xff && (b[1] & 0xf8) == 0xf8)
found = 2;
else {
c++;
p
->
found
++
;
}
if
(
c
==
count
)
return
count
;
}
if
(
p
->
mpeg
==
1
&&
p
->
which
<
2000
)
{
if (!found) return -1;
if
(
p
->
found
==
7
)
{
p
->
check
=
p
->
flag1
;
p
->
hlength
=
1
;
if (c+3 >= count) return -1;
headr = mbuf+c;
ai->layer = (headr[1] & 0x06) >> 1;
if (pr)
printk("Audiostream: Layer: %d", 4-ai->layer);
ai->bit_rate = bitrates[(3-ai->layer)][(headr[2] >> 4 )]*1000;
if (pr){
if (ai->bit_rate == 0)
printk(" Bit rate: free");
else if (ai->bit_rate == 0xf)
printk(" BRate: reserved");
else
printk(" BRate: %d kb/s", ai->bit_rate/1000);
}
while
(
!
p
->
which
&&
c
<
count
&&
p
->
check
==
0xFF
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
fr = (headr[2] & 0x0c ) >> 2;
ai->frequency = freq[fr]*100;
if (pr){
if (ai->frequency == 3)
printk(" Freq: reserved\n");
else
printk(" Freq: %d kHz\n",ai->frequency);
}
ai->off = c;
return 0;
}
#endif
if
(
c
==
count
)
return
count
;
static
int
get_ac3info
(
uint8_t
*
mbuf
,
int
count
,
AudioInfo
*
ai
,
int
pr
)
{
uint8_t
*
headr
;
int
found
=
0
;
int
c
=
0
;
uint8_t
frame
=
0
;
int
fr
=
0
;
if
(
(
p
->
check
&
0xC0
)
==
0x40
&&
!
p
->
which
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
while
(
!
found
&&
c
<
count
){
uint8_t
*
b
=
mbuf
+
c
;
p
->
which
=
1
;
if
(
c
==
count
)
return
count
;
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
if
(
b
[
0
]
==
0x0b
&&
b
[
1
]
==
0x77
)
found
=
1
;
else
{
c
++
;
p
->
found
++
;
p
->
hlength
++
;
p
->
which
=
2
;
if
(
c
==
count
)
return
count
;
}
if
(
p
->
which
==
1
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
p
->
which
=
2
;
if
(
c
==
count
)
return
count
;
}
if
(
(
p
->
check
&
0x30
)
&&
p
->
check
!=
0xFF
){
p
->
flag2
=
(
p
->
check
&
0xF0
)
<<
2
;
p
->
pts
[
0
]
=
p
->
check
;
p
->
which
=
3
;
}
if
(
c
==
count
)
return
count
;
if
(
p
->
which
>
2
){
if
((
p
->
flag2
&
PTS_DTS_FLAGS
)
==
PTS_ONLY
){
while
(
c
<
count
&&
p
->
which
<
7
){
p
->
pts
[
p
->
which
-
2
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
which
++
;
p
->
hlength
++
;
}
if
(
c
==
count
)
return
count
;
}
else
if
((
p
->
flag2
&
PTS_DTS_FLAGS
)
==
PTS_DTS
){
while
(
c
<
count
&&
p
->
which
<
12
){
if
(
p
->
which
<
7
)
p
->
pts
[
p
->
which
-
2
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
which
++
;
p
->
hlength
++
;
}
if
(
c
==
count
)
return
count
;
}
p
->
which
=
2000
;
}
if
(
!
found
)
return
-
1
;
if
(
pr
)
printk
(
"Audiostream: AC3"
);
}
ai
->
off
=
c
;
if
(
c
+
5
>=
count
)
return
-
1
;
while
(
c
<
count
&&
p
->
found
<
p
->
plength
+
6
){
l
=
count
-
c
;
if
(
l
+
p
->
found
>
p
->
plength
+
6
)
l
=
p
->
plength
+
6
-
p
->
found
;
write_ipack
(
p
,
buf
+
c
,
l
);
p
->
found
+=
l
;
c
+=
l
;
}
ai
->
layer
=
0
;
// 0 for AC3
headr
=
mbuf
+
c
+
2
;
break
;
}
frame
=
(
headr
[
2
]
&
0x3f
)
;
ai
->
bit_rate
=
ac3_bitrates
[
frame
>>
1
]
*
1000
;
if
(
pr
)
printk
(
" BRate: %d kb/s"
,
ai
->
bit_rate
/
1000
);
if
(
p
->
done
){
if
(
p
->
found
+
count
-
c
<
p
->
plength
+
6
){
p
->
found
+=
count
-
c
;
c
=
count
;
}
else
{
c
+=
p
->
plength
+
6
-
p
->
found
;
p
->
found
=
p
->
plength
+
6
;
}
}
ai
->
frequency
=
(
headr
[
2
]
&
0xc0
)
>>
6
;
fr
=
(
headr
[
2
]
&
0xc0
)
>>
6
;
ai
->
frequency
=
freq
[
fr
]
*
100
;
if
(
pr
)
printk
(
" Freq: %d Hz
\n
"
,
ai
->
frequency
);
if
(
p
->
plength
&&
p
->
found
==
p
->
plength
+
6
)
{
send_ipack
(
p
);
reset_ipack
(
p
);
if
(
c
<
count
)
instant_repack
(
buf
+
c
,
count
-
c
,
p
);
}
}
return
count
;
}
ai
->
framesize
=
ac3_frames
[
fr
][
frame
>>
1
];
if
((
frame
&
1
)
&&
(
fr
==
1
))
ai
->
framesize
++
;
ai
->
framesize
=
ai
->
framesize
<<
1
;
if
(
pr
)
printk
(
" Framesize %d
\n
"
,
ai
->
framesize
);
void
setup_ts2pes
(
ipack
*
pa
,
ipack
*
pv
,
u16
*
pida
,
u16
*
pidv
,
void
(
*
pes_write
)(
u8
*
buf
,
int
count
,
void
*
data
),
void
*
priv
)
{
init_ipack
(
pa
,
IPACKS
,
pes_write
);
init_ipack
(
pv
,
IPACKS
,
pes_write
);
pa
->
pid
=
pida
;
pv
->
pid
=
pidv
;
pa
->
data
=
priv
;
pv
->
data
=
priv
;
return
0
;
}
void
ts_to_pes
(
ipack
*
p
,
u8
*
buf
)
// don't need count (=188)
{
u8
off
=
0
;
if
(
!
buf
||
!
p
){
printk
(
"NULL POINTER IDIOT
\n
"
);
return
;
}
if
(
buf
[
1
]
&
PAY_START
)
{
if
(
p
->
plength
==
MMAX_PLENGTH
-
6
&&
p
->
found
>
6
){
p
->
plength
=
p
->
found
-
6
;
p
->
found
=
0
;
send_ipack
(
p
);
reset_ipack
(
p
);
}
}
if
(
buf
[
3
]
&
ADAPT_FIELD
)
{
// adaptation field?
off
=
buf
[
4
]
+
1
;
if
(
off
+
4
>
187
)
return
;
}
instant_repack
(
buf
+
4
+
off
,
TS_SIZE
-
4
-
off
,
p
);
}
/* needs 5 byte input, returns picture coding type*/
int
read_picture_header
(
uint8_t
*
headr
,
mpg_picture
*
pic
,
int
field
,
int
pr
)
#if 0
static
uint8_t *skip_pes_header(uint8_t **bufp)
{
uint8_t
pct
;
uint8_t *inbuf = *bufp;
uint8_t *buf = inbuf;
uint8_t *pts = NULL;
int skip = 0;
if
(
pr
)
printk
(
"Pic header: "
);
pic
->
temporal_reference
[
field
]
=
((
headr
[
0
]
<<
2
)
|
(
headr
[
1
]
&
0x03
)
)
&
0x03ff
;
if
(
pr
)
printk
(
" temp ref: 0x%04x"
,
pic
->
temporal_reference
[
field
])
;
static const int mpeg1_skip_table[16] = {
1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
}
;
pct
=
(
headr
[
1
]
>>
2
)
&
0x07
;
pic
->
picture_coding_type
[
field
]
=
pct
;
if
(
pr
)
{
switch
(
pct
){
case
I_FRAME
:
printk
(
" I-FRAME"
);
break
;
case
B_FRAME
:
printk
(
" B-FRAME"
);
break
;
case
P_FRAME
:
printk
(
" P-FRAME"
);
if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */
if (buf[7] & PTS_ONLY)
pts = buf+9;
else pts = NULL;
buf = inbuf + 9 + inbuf[8];
} else { /* mpeg1 */
for (buf = inbuf + 6; *buf == 0xff; buf++)
if (buf == inbuf + 6 + 16) {
break;
}
}
pic
->
vinfo
.
vbv_delay
=
((
headr
[
1
]
>>
5
)
|
(
headr
[
2
]
<<
3
)
|
(
(
headr
[
3
]
&
0x1F
)
<<
11
)
)
&
0xffff
;
if
(
pr
)
printk
(
" vbv delay: 0x%04x"
,
pic
->
vinfo
.
vbv_delay
);
pic
->
picture_header_parameter
=
(
headr
[
3
]
&
0xe0
)
|
((
headr
[
4
]
&
0x80
)
>>
3
);
if ((*buf & 0xc0) == 0x40)
buf += 2;
skip = mpeg1_skip_table [*buf >> 4];
if (skip == 5 || skip == 10) pts = buf;
else pts = NULL;
if
(
pct
==
B_FRAME
){
pic
->
picture_header_parameter
|=
(
headr
[
4
]
>>
3
)
&
0x0f
;
buf += mpeg1_skip_table [*buf >> 4];
}
if
(
pr
)
printk
(
" pic head param: 0x%x"
,
pic
->
picture_header_parameter
);
return
pct
;
*bufp = buf;
return pts;
}
#endif
/* needs 4 byte input */
int
read_gop_header
(
uint8_t
*
headr
,
mpg_picture
*
pic
,
int
pr
)
#if 0
static
void initialize_quant_matrix( uint32_t *matrix
)
{
if
(
pr
)
printk
(
"GOP header: "
);
int i;
pic
->
time_code
=
((
headr
[
0
]
<<
17
)
|
(
headr
[
1
]
<<
9
)
|
(
headr
[
2
]
<<
1
)
|
(
headr
[
3
]
&
0x01
))
&
0x1ffffff
;
matrix[0] = 0x08101013;
matrix[1] = 0x10131616;
matrix[2] = 0x16161616;
matrix[3] = 0x1a181a1b;
matrix[4] = 0x1b1b1a1a;
matrix[5] = 0x1a1a1b1b;
matrix[6] = 0x1b1d1d1d;
matrix[7] = 0x2222221d;
matrix[8] = 0x1d1d1b1b;
matrix[9] = 0x1d1d2020;
matrix[10] = 0x22222526;
matrix[11] = 0x25232322;
matrix[12] = 0x23262628;
matrix[13] = 0x28283030;
matrix[14] = 0x2e2e3838;
matrix[15] = 0x3a454553;
if
(
pr
)
printk
(
" time: %d:%d.%d "
,
(
headr
[
0
]
>>
2
)
&
0x1F
,
((
headr
[
0
]
<<
4
)
&
0x30
)
|
((
headr
[
1
]
>>
4
)
&
0x0F
),
((
headr
[
1
]
<<
3
)
&
0x38
)
|
((
headr
[
2
]
>>
5
)
&
0x0F
));
for ( i = 16 ; i < 32 ; i++ )
matrix[i] = 0x10101010;
}
#endif
if
(
(
headr
[
3
]
&
0x40
)
!=
0
){
pic
->
closed_gop
=
1
;
}
else
{
pic
->
closed_gop
=
0
;
}
if
(
pr
)
printk
(
"closed: %d"
,
pic
->
closed_gop
);
#if 0
static
void initialize_mpg_picture(mpg_picture *pic)
{
int i;
if
(
(
headr
[
3
]
&
0x20
)
!=
0
){
pic
->
broken_link
=
1
;
}
else
{
pic
->
broken_link
=
0
;
/* set MPEG1 */
pic->mpeg1_flag = 1;
pic->profile_and_level = 0x4A ; /* MP@LL */
pic->progressive_sequence = 1;
pic->low_delay = 0;
pic->sequence_display_extension_flag = 0;
for ( i = 0 ; i < 4 ; i++ ){
pic->frame_centre_horizontal_offset[i] = 0;
pic->frame_centre_vertical_offset[i] = 0;
}
if
(
pr
)
printk
(
" broken: %d
\n
"
,
pic
->
broken_link
);
pic->last_frame_centre_horizontal_offset = 0;
pic->last_frame_centre_vertical_offset = 0;
return
0
;
pic->picture_display_extension_flag[0] = 0;
pic->picture_display_extension_flag[1] = 0;
pic->sequence_header_flag = 0;
pic->gop_flag = 0;
pic->sequence_end_flag = 0;
}
#endif
/* needs 8 byte input */
int
read_sequence_header
(
uint8_t
*
headr
,
VideoInfo
*
vi
,
int
pr
)
#if 0
static
void mpg_set_picture_parameter( int32_t field_type, mpg_picture *pic )
{
int
sw
;
int
form
=
-
1
;
int
16_t last_h_offset
;
int16_t last_v_offset
;
if
(
pr
)
printk
(
"Reading sequence header
\n
"
);
int16_t *p_h_offset;
int16_t *p_v_offset;
vi
->
horizontal_size
=
((
headr
[
1
]
&
0xF0
)
>>
4
)
|
(
headr
[
0
]
<<
4
);
vi
->
vertical_size
=
((
headr
[
1
]
&
0x0F
)
<<
8
)
|
(
headr
[
2
]);
if ( pic->mpeg1_flag ){
pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE;
pic->top_field_first = 0;
pic->repeat_first_field = 0;
pic->progressive_frame = 1;
pic->picture_coding_parameter = 0x000010;
}
sw
=
(
int
)((
headr
[
3
]
&
0xF0
)
>>
4
)
;
/* Reset flag */
pic->picture_display_extension_flag[field_type] = 0;
switch
(
sw
){
case
1
:
if
(
pr
)
printk
(
"Videostream: ASPECT: 1:1"
);
vi
->
aspect_ratio
=
100
;
break
;
case
2
:
if
(
pr
)
printk
(
"Videostream: ASPECT: 4:3"
);
vi
->
aspect_ratio
=
133
;
break
;
case
3
:
if
(
pr
)
printk
(
"Videostream: ASPECT: 16:9"
);
vi
->
aspect_ratio
=
177
;
break
;
case
4
:
if
(
pr
)
printk
(
"Videostream: ASPECT: 2.21:1"
);
vi
->
aspect_ratio
=
221
;
break
;
case
5
...
15
:
if
(
pr
)
printk
(
"Videostream: ASPECT: reserved"
);
vi
->
aspect_ratio
=
0
;
break
;
default:
vi
->
aspect_ratio
=
0
;
return
-
1
;
last_h_offset = pic->last_frame_centre_horizontal_offset;
last_v_offset = pic->last_frame_centre_vertical_offset;
if ( field_type == FIRST_FIELD ){
p_h_offset = pic->frame_centre_horizontal_offset;
p_v_offset = pic->frame_centre_vertical_offset;
*p_h_offset = last_h_offset;
*(p_h_offset + 1) = last_h_offset;
*(p_h_offset + 2) = last_h_offset;
*p_v_offset = last_v_offset;
*(p_v_offset + 1) = last_v_offset;
*(p_v_offset + 2) = last_v_offset;
} else {
pic->frame_centre_horizontal_offset[3] = last_h_offset;
pic->frame_centre_vertical_offset[3] = last_v_offset;
}
}
#endif
if
(
pr
)
printk
(
" Size = %dx%d"
,
vi
->
horizontal_size
,
vi
->
vertical_size
);
sw
=
(
int
)(
headr
[
3
]
&
0x0F
);
#if 0
static
void init_mpg_picture( mpg_picture *pic, int chan, int32_t field_type)
{
pic->picture_header = 0;
pic->sequence_header_data
= ( INIT_HORIZONTAL_SIZE << 20 )
| ( INIT_VERTICAL_SIZE << 8 )
| ( INIT_ASPECT_RATIO << 4 )
| ( INIT_FRAME_RATE );
pic->mpeg1_flag = 0;
pic->vinfo.horizontal_size
= INIT_DISP_HORIZONTAL_SIZE;
pic->vinfo.vertical_size
= INIT_DISP_VERTICAL_SIZE;
pic->picture_display_extension_flag[field_type]
= 0;
pic->pts_flag[field_type] = 0;
switch
(
sw
)
{
case
1
:
if
(
pr
)
printk
(
" FRate: 23.976 fps"
);
vi
->
framerate
=
23976
;
form
=
-
1
;
break
;
case
2
:
if
(
pr
)
printk
(
" FRate: 24 fps"
);
vi
->
framerate
=
24000
;
form
=
-
1
;
break
;
case
3
:
if
(
pr
)
printk
(
" FRate: 25 fps"
);
vi
->
framerate
=
25000
;
form
=
VIDEO_MODE_PAL
;
break
;
case
4
:
if
(
pr
)
printk
(
" FRate: 29.97 fps"
);
vi
->
framerate
=
29970
;
form
=
VIDEO_MODE_NTSC
;
break
;
case
5
:
if
(
pr
)
printk
(
" FRate: 30 fps"
);
vi
->
framerate
=
30000
;
form
=
VIDEO_MODE_NTSC
;
break
;
case
6
:
if
(
pr
)
printk
(
" FRate: 50 fps"
);
vi
->
framerate
=
50000
;
form
=
VIDEO_MODE_PAL
;
break
;
case
7
:
if
(
pr
)
printk
(
" FRate: 60 fps"
);
vi
->
framerate
=
60000
;
form
=
VIDEO_MODE_NTSC
;
break
;
}
pic->sequence_gop_header = 0;
pic->picture_header = 0;
pic->sequence_header_flag = 0;
pic->gop_flag = 0;
pic->sequence_end_flag = 0;
pic->sequence_display_extension_flag = 0;
pic->last_frame_centre_horizontal_offset = 0;
pic->last_frame_centre_vertical_offset = 0;
pic->channel = chan;
}
#endif
vi
->
bit_rate
=
(
headr
[
4
]
<<
10
)
|
(
headr
[
5
]
<<
2
)
|
(
headr
[
6
]
&
0x03
);
void
dvb_filter_pes2ts_init
(
dvb_filter_pes2ts_t
*
p2ts
,
unsigned
short
pid
,
dvb_filter_pes2ts_cb_t
*
cb
,
void
*
priv
)
{
unsigned
char
*
buf
=
p2ts
->
buf
;
vi
->
vbv_buffer_size
=
((
headr
[
6
]
&
0xF8
)
>>
3
)
|
((
headr
[
7
]
&
0x1F
)
<<
5
);
buf
[
0
]
=
0x47
;
buf
[
1
]
=
(
pid
>>
8
);
buf
[
2
]
=
pid
&
0xff
;
p2ts
->
cc
=
0
;
p2ts
->
cb
=
cb
;
p2ts
->
priv
=
priv
;
}
if
(
pr
){
printk
(
" BRate: %d Mbit/s"
,
4
*
(
vi
->
bit_rate
)
/
10000
);
printk
(
" vbvbuffer %d"
,
16
*
1024
*
(
vi
->
vbv_buffer_size
));
printk
(
"
\n
"
);
}
int
dvb_filter_pes2ts
(
dvb_filter_pes2ts_t
*
p2ts
,
unsigned
char
*
pes
,
int
len
)
{
unsigned
char
*
buf
=
p2ts
->
buf
;
int
ret
=
0
,
rest
;
vi
->
video_format
=
form
;
//len=6+((pes[4]<<8)|pes[5])
;
buf
[
1
]
|=
0x40
;
while
(
len
>=
184
)
{
buf
[
3
]
=
0x10
|
((
p2ts
->
cc
++
)
&
0x0f
);
memcpy
(
buf
+
4
,
pes
,
184
);
if
((
ret
=
p2ts
->
cb
(
p2ts
->
priv
,
buf
)))
return
ret
;
len
-=
184
;
pes
+=
184
;
buf
[
1
]
&=~
0x40
;
}
if
(
!
len
)
return
0
;
buf
[
3
]
=
0x30
|
((
p2ts
->
cc
++
)
&
0x0f
);
rest
=
183
-
len
;
if
(
rest
)
{
buf
[
5
]
=
0x00
;
if
(
rest
-
1
)
memset
(
buf
+
6
,
0xff
,
rest
-
1
);
}
buf
[
4
]
=
rest
;
memcpy
(
buf
+
5
+
rest
,
pes
,
len
);
return
p2ts
->
cb
(
p2ts
->
priv
,
buf
);
}
int
get_vinfo
(
uint8_t
*
mbuf
,
int
count
,
VideoInfo
*
vi
,
int
pr
)
void
dvb_filter_ipack_reset
(
ipack
*
p
)
{
uint8_t
*
headr
;
int
found
=
0
;
int
c
=
0
;
while
(
found
<
4
&&
c
+
4
<
count
){
uint8_t
*
b
;
p
->
found
=
0
;
p
->
cid
=
0
;
p
->
plength
=
0
;
p
->
flag1
=
0
;
p
->
flag2
=
0
;
p
->
hlength
=
0
;
p
->
mpeg
=
0
;
p
->
check
=
0
;
p
->
which
=
0
;
p
->
done
=
0
;
p
->
count
=
0
;
}
b
=
mbuf
+
c
;
if
(
b
[
0
]
==
0x00
&&
b
[
1
]
==
0x00
&&
b
[
2
]
==
0x01
&&
b
[
3
]
==
0xb3
)
found
=
4
;
else
{
c
++
;
}
void
dvb_filter_ipack_init
(
ipack
*
p
,
int
size
,
void
(
*
func
)(
u8
*
buf
,
int
size
,
void
*
priv
))
{
if
(
!
(
p
->
buf
=
vmalloc
(
size
*
sizeof
(
u8
)))
){
printk
(
"Couldn't allocate memory for ipack
\n
"
);
}
p
->
size
=
size
;
p
->
func
=
func
;
p
->
repack_subids
=
0
;
dvb_filter_ipack_reset
(
p
);
}
if
(
!
found
)
return
-
1
;
c
+=
4
;
if
(
c
+
12
>=
count
)
return
-
1
;
headr
=
mbuf
+
c
;
if
(
read_sequence_header
(
headr
,
vi
,
pr
)
<
0
)
return
-
1
;
vi
->
off
=
c
-
4
;
return
0
;
void
dvb_filter_ipack_free
(
ipack
*
p
)
{
if
(
p
->
buf
)
vfree
(
p
->
buf
);
}
int
get_ainfo
(
uint8_t
*
mbuf
,
int
count
,
AudioInfo
*
ai
,
int
pr
)
static
void
send_ipack
(
ipack
*
p
)
{
uint8_t
*
headr
;
int
found
=
0
;
int
c
=
0
;
int
fr
=
0
;
int
off
;
AudioInfo
ai
;
int
ac3_off
=
0
;
int
streamid
=
0
;
int
nframes
=
0
;
int
f
=
0
;
while
(
found
<
2
&&
c
<
count
){
uint8_t
b
[
2
];
memcpy
(
b
,
mbuf
+
c
,
2
);
switch
(
p
->
mpeg
){
case
2
:
if
(
p
->
count
<
10
)
return
;
p
->
buf
[
3
]
=
p
->
cid
;
if
(
b
[
0
]
==
0xff
&&
(
b
[
1
]
&
0xf8
)
==
0xf8
)
found
=
2
;
else
{
c
++
;
p
->
buf
[
4
]
=
(
u8
)(((
p
->
count
-
6
)
&
0xFF00
)
>>
8
);
p
->
buf
[
5
]
=
(
u8
)((
p
->
count
-
6
)
&
0x00FF
);
if
(
p
->
repack_subids
&&
p
->
cid
==
PRIVATE_STREAM1
){
off
=
9
+
p
->
buf
[
8
];
streamid
=
p
->
buf
[
off
];
if
((
streamid
&
0xF8
)
==
0x80
){
ai
.
off
=
0
;
ac3_off
=
((
p
->
buf
[
off
+
2
]
<<
8
)
|
p
->
buf
[
off
+
3
]);
if
(
ac3_off
<
p
->
count
)
f
=
get_ac3info
(
p
->
buf
+
off
+
3
+
ac3_off
,
p
->
count
-
ac3_off
,
&
ai
,
0
);
if
(
!
f
){
nframes
=
(
p
->
count
-
off
-
3
-
ac3_off
)
/
ai
.
framesize
+
1
;
p
->
buf
[
off
+
2
]
=
(
ac3_off
>>
8
)
&
0xFF
;
p
->
buf
[
off
+
3
]
=
(
ac3_off
)
&
0xFF
;
p
->
buf
[
off
+
1
]
=
nframes
;
ac3_off
+=
nframes
*
ai
.
framesize
-
p
->
count
;
}
}
}
p
->
func
(
p
->
buf
,
p
->
count
,
p
->
data
);
if
(
!
found
)
return
-
1
;
p
->
buf
[
6
]
=
0x80
;
p
->
buf
[
7
]
=
0x00
;
p
->
buf
[
8
]
=
0x00
;
p
->
count
=
9
;
if
(
p
->
repack_subids
&&
p
->
cid
==
PRIVATE_STREAM1
&&
(
streamid
&
0xF8
)
==
0x80
){
p
->
count
+=
4
;
p
->
buf
[
9
]
=
streamid
;
p
->
buf
[
10
]
=
(
ac3_off
>>
8
)
&
0xFF
;
p
->
buf
[
11
]
=
(
ac3_off
)
&
0xFF
;
p
->
buf
[
12
]
=
0
;
}
if
(
c
+
3
>=
count
)
return
-
1
;
headr
=
mbuf
+
c
;
break
;
case
1
:
if
(
p
->
count
<
8
)
return
;
p
->
buf
[
3
]
=
p
->
cid
;
ai
->
layer
=
(
headr
[
1
]
&
0x06
)
>>
1
;
p
->
buf
[
4
]
=
(
u8
)(((
p
->
count
-
6
)
&
0xFF00
)
>>
8
);
p
->
buf
[
5
]
=
(
u8
)((
p
->
count
-
6
)
&
0x00FF
);
p
->
func
(
p
->
buf
,
p
->
count
,
p
->
data
);
if
(
pr
)
printk
(
"Audiostream: Layer: %d"
,
4
-
ai
->
layer
);
p
->
buf
[
6
]
=
0x0F
;
p
->
count
=
7
;
break
;
}
}
void
dvb_filter_ipack_flush
(
ipack
*
p
)
{
if
(
p
->
plength
!=
MMAX_PLENGTH
-
6
||
p
->
found
<=
6
)
return
;
p
->
plength
=
p
->
found
-
6
;
p
->
found
=
0
;
send_ipack
(
p
);
dvb_filter_ipack_reset
(
p
);
}
ai
->
bit_rate
=
bitrates
[(
3
-
ai
->
layer
)][(
headr
[
2
]
>>
4
)]
*
1000
;
static
void
write_ipack
(
ipack
*
p
,
u8
*
data
,
int
count
)
{
u8
headr
[
3
]
=
{
0x00
,
0x00
,
0x01
}
;
if
(
pr
){
if
(
ai
->
bit_rate
==
0
)
printk
(
" Bit rate: free"
);
else
if
(
ai
->
bit_rate
==
0xf
)
printk
(
" BRate: reserved"
);
else
printk
(
" BRate: %d kb/s"
,
ai
->
bit_rate
/
1000
);
if
(
p
->
count
<
6
){
memcpy
(
p
->
buf
,
headr
,
3
);
p
->
count
=
6
;
}
fr
=
(
headr
[
2
]
&
0x0c
)
>>
2
;
ai
->
frequency
=
freq
[
fr
]
*
100
;
if
(
pr
){
if
(
ai
->
frequency
==
3
)
printk
(
" Freq: reserved
\n
"
);
else
printk
(
" Freq: %d kHz
\n
"
,
ai
->
frequency
);
if
(
p
->
count
+
count
<
p
->
size
){
memcpy
(
p
->
buf
+
p
->
count
,
data
,
count
);
p
->
count
+=
count
;
}
else
{
int
rest
=
p
->
size
-
p
->
count
;
memcpy
(
p
->
buf
+
p
->
count
,
data
,
rest
);
p
->
count
+=
rest
;
send_ipack
(
p
);
if
(
count
-
rest
>
0
)
write_ipack
(
p
,
data
+
rest
,
count
-
rest
);
}
ai
->
off
=
c
;
return
0
;
}
int
get_ac3info
(
uint8_t
*
mbuf
,
int
count
,
AudioInfo
*
ai
,
int
pr
)
int
dvb_filter_instant_repack
(
u8
*
buf
,
int
count
,
ipack
*
p
)
{
uint8_t
*
headr
;
int
found
=
0
;
int
c
=
0
;
uint8_t
frame
=
0
;
int
fr
=
0
;
int
l
;
int
c
=
0
;
while
(
!
found
&&
c
<
count
){
uint8_t
*
b
=
mbuf
+
c
;
while
(
c
<
count
&&
(
p
->
mpeg
==
0
||
(
p
->
mpeg
==
1
&&
p
->
found
<
7
)
||
(
p
->
mpeg
==
2
&&
p
->
found
<
9
))
&&
(
p
->
found
<
5
||
!
p
->
done
)){
switch
(
p
->
found
){
case
0
:
case
1
:
if
(
buf
[
c
]
==
0x00
)
p
->
found
++
;
else
p
->
found
=
0
;
c
++
;
break
;
case
2
:
if
(
buf
[
c
]
==
0x01
)
p
->
found
++
;
else
if
(
buf
[
c
]
==
0
)
{
p
->
found
=
2
;
}
else
p
->
found
=
0
;
c
++
;
break
;
case
3
:
p
->
cid
=
0
;
switch
(
buf
[
c
]){
case
PROG_STREAM_MAP
:
case
PRIVATE_STREAM2
:
case
PROG_STREAM_DIR
:
case
ECM_STREAM
:
case
EMM_STREAM
:
case
PADDING_STREAM
:
case
DSM_CC_STREAM
:
case
ISO13522_STREAM
:
p
->
done
=
1
;
case
PRIVATE_STREAM1
:
case
VIDEO_STREAM_S
...
VIDEO_STREAM_E
:
case
AUDIO_STREAM_S
...
AUDIO_STREAM_E
:
p
->
found
++
;
p
->
cid
=
buf
[
c
];
c
++
;
break
;
default:
p
->
found
=
0
;
break
;
}
break
;
if
(
b
[
0
]
==
0x0b
&&
b
[
1
]
==
0x77
)
found
=
1
;
else
{
case
4
:
if
(
count
-
c
>
1
){
p
->
plen
[
0
]
=
buf
[
c
];
c
++
;
p
->
plen
[
1
]
=
buf
[
c
];
c
++
;
p
->
found
+=
2
;
p
->
plength
=
(
p
->
plen
[
0
]
<<
8
)
|
p
->
plen
[
1
];
}
else
{
p
->
plen
[
0
]
=
buf
[
c
];
p
->
found
++
;
return
count
;
}
break
;
case
5
:
p
->
plen
[
1
]
=
buf
[
c
];
c
++
;
p
->
found
++
;
p
->
plength
=
(
p
->
plen
[
0
]
<<
8
)
|
p
->
plen
[
1
];
break
;
case
6
:
if
(
!
p
->
done
){
p
->
flag1
=
buf
[
c
];
c
++
;
p
->
found
++
;
if
(
(
p
->
flag1
&
0xC0
)
==
0x80
)
p
->
mpeg
=
2
;
else
{
p
->
hlength
=
0
;
p
->
which
=
0
;
p
->
mpeg
=
1
;
p
->
flag2
=
0
;
}
}
break
;
if
(
!
found
)
return
-
1
;
if
(
pr
)
printk
(
"Audiostream: AC3"
);
ai
->
off
=
c
;
if
(
c
+
5
>=
count
)
return
-
1
;
ai
->
layer
=
0
;
// 0 for AC3
headr
=
mbuf
+
c
+
2
;
frame
=
(
headr
[
2
]
&
0x3f
);
ai
->
bit_rate
=
ac3_bitrates
[
frame
>>
1
]
*
1000
;
case
7
:
if
(
!
p
->
done
&&
p
->
mpeg
==
2
)
{
p
->
flag2
=
buf
[
c
];
c
++
;
p
->
found
++
;
}
break
;
if
(
pr
)
printk
(
" BRate: %d kb/s"
,
ai
->
bit_rate
/
1000
);
case
8
:
if
(
!
p
->
done
&&
p
->
mpeg
==
2
)
{
p
->
hlength
=
buf
[
c
];
c
++
;
p
->
found
++
;
}
break
;
ai
->
frequency
=
(
headr
[
2
]
&
0xc0
)
>>
6
;
fr
=
(
headr
[
2
]
&
0xc0
)
>>
6
;
ai
->
frequency
=
freq
[
fr
]
*
100
;
if
(
pr
)
printk
(
" Freq: %d Hz
\n
"
,
ai
->
frequency
);
default:
break
;
}
}
ai
->
framesize
=
ac3_frames
[
fr
][
frame
>>
1
];
if
((
frame
&
1
)
&&
(
fr
==
1
))
ai
->
framesize
++
;
ai
->
framesize
=
ai
->
framesize
<<
1
;
if
(
pr
)
printk
(
" Framesize %d
\n
"
,
ai
->
framesize
);
if
(
c
==
count
)
return
count
;
if
(
!
p
->
plength
)
p
->
plength
=
MMAX_PLENGTH
-
6
;
return
0
;
}
if
(
p
->
done
||
((
p
->
mpeg
==
2
&&
p
->
found
>=
9
)
||
(
p
->
mpeg
==
1
&&
p
->
found
>=
7
))
){
switch
(
p
->
cid
){
uint8_t
*
skip_pes_header
(
uint8_t
**
bufp
)
{
uint8_t
*
inbuf
=
*
bufp
;
uint8_t
*
buf
=
inbuf
;
uint8_t
*
pts
=
NULL
;
int
skip
=
0
;
case
AUDIO_STREAM_S
...
AUDIO_STREAM_E
:
case
VIDEO_STREAM_S
...
VIDEO_STREAM_E
:
case
PRIVATE_STREAM1
:
int
mpeg1_skip_table
[
16
]
=
{
1
,
0xffff
,
5
,
10
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
,
0xffff
};
if
(
p
->
mpeg
==
2
&&
p
->
found
==
9
)
{
write_ipack
(
p
,
&
p
->
flag1
,
1
);
write_ipack
(
p
,
&
p
->
flag2
,
1
);
write_ipack
(
p
,
&
p
->
hlength
,
1
);
}
if
(
p
->
mpeg
==
1
&&
p
->
found
==
7
)
write_ipack
(
p
,
&
p
->
flag1
,
1
);
if
((
inbuf
[
6
]
&
0xc0
)
==
0x80
){
/* mpeg2 */
if
(
buf
[
7
]
&
PTS_ONLY
)
pts
=
buf
+
9
;
else
pts
=
NULL
;
buf
=
inbuf
+
9
+
inbuf
[
8
];
}
else
{
/* mpeg1 */
for
(
buf
=
inbuf
+
6
;
*
buf
==
0xff
;
buf
++
)
if
(
buf
==
inbuf
+
6
+
16
)
{
break
;
if
(
p
->
mpeg
==
2
&&
(
p
->
flag2
&
PTS_ONLY
)
&&
p
->
found
<
14
)
{
while
(
c
<
count
&&
p
->
found
<
14
)
{
p
->
pts
[
p
->
found
-
9
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
}
if
((
*
buf
&
0xc0
)
==
0x40
)
buf
+=
2
;
skip
=
mpeg1_skip_table
[
*
buf
>>
4
];
if
(
skip
==
5
||
skip
==
10
)
pts
=
buf
;
else
pts
=
NULL
;
buf
+=
mpeg1_skip_table
[
*
buf
>>
4
];
if
(
c
==
count
)
return
count
;
}
*
bufp
=
buf
;
return
pts
;
}
if
(
p
->
mpeg
==
1
&&
p
->
which
<
2000
)
{
void
initialize_quant_matrix
(
uint32_t
*
matrix
)
{
int
i
;
if
(
p
->
found
==
7
)
{
p
->
check
=
p
->
flag1
;
p
->
hlength
=
1
;
}
matrix
[
0
]
=
0x08101013
;
matrix
[
1
]
=
0x10131616
;
matrix
[
2
]
=
0x16161616
;
matrix
[
3
]
=
0x1a181a1b
;
matrix
[
4
]
=
0x1b1b1a1a
;
matrix
[
5
]
=
0x1a1a1b1b
;
matrix
[
6
]
=
0x1b1d1d1d
;
matrix
[
7
]
=
0x2222221d
;
matrix
[
8
]
=
0x1d1d1b1b
;
matrix
[
9
]
=
0x1d1d2020
;
matrix
[
10
]
=
0x22222526
;
matrix
[
11
]
=
0x25232322
;
matrix
[
12
]
=
0x23262628
;
matrix
[
13
]
=
0x28283030
;
matrix
[
14
]
=
0x2e2e3838
;
matrix
[
15
]
=
0x3a454553
;
while
(
!
p
->
which
&&
c
<
count
&&
p
->
check
==
0xFF
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
}
for
(
i
=
16
;
i
<
32
;
i
++
)
matrix
[
i
]
=
0x10101010
;
}
if
(
c
==
count
)
return
count
;
void
initialize_mpg_picture
(
mpg_picture
*
pic
)
{
int
i
;
if
(
(
p
->
check
&
0xC0
)
==
0x40
&&
!
p
->
which
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
/* set MPEG1 */
pic
->
mpeg1_flag
=
1
;
pic
->
profile_and_level
=
0x4A
;
/* MP@LL */
pic
->
progressive_sequence
=
1
;
pic
->
low_delay
=
0
;
p
->
which
=
1
;
if
(
c
==
count
)
return
count
;
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
p
->
which
=
2
;
if
(
c
==
count
)
return
count
;
}
pic
->
sequence_display_extension_flag
=
0
;
for
(
i
=
0
;
i
<
4
;
i
++
){
pic
->
frame_centre_horizontal_offset
[
i
]
=
0
;
pic
->
frame_centre_vertical_offset
[
i
]
=
0
;
if
(
p
->
which
==
1
){
p
->
check
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
hlength
++
;
p
->
which
=
2
;
if
(
c
==
count
)
return
count
;
}
pic
->
last_frame_centre_horizontal_offset
=
0
;
pic
->
last_frame_centre_vertical_offset
=
0
;
pic
->
picture_display_extension_flag
[
0
]
=
0
;
pic
->
picture_display_extension_flag
[
1
]
=
0
;
pic
->
sequence_header_flag
=
0
;
pic
->
gop_flag
=
0
;
pic
->
sequence_end_flag
=
0
;
}
if
(
(
p
->
check
&
0x30
)
&&
p
->
check
!=
0xFF
){
p
->
flag2
=
(
p
->
check
&
0xF0
)
<<
2
;
p
->
pts
[
0
]
=
p
->
check
;
p
->
which
=
3
;
}
if
(
c
==
count
)
return
count
;
if
(
p
->
which
>
2
){
if
((
p
->
flag2
&
PTS_DTS_FLAGS
)
==
PTS_ONLY
){
while
(
c
<
count
&&
p
->
which
<
7
){
p
->
pts
[
p
->
which
-
2
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
which
++
;
p
->
hlength
++
;
}
if
(
c
==
count
)
return
count
;
}
else
if
((
p
->
flag2
&
PTS_DTS_FLAGS
)
==
PTS_DTS
){
while
(
c
<
count
&&
p
->
which
<
12
){
if
(
p
->
which
<
7
)
p
->
pts
[
p
->
which
-
2
]
=
buf
[
c
];
write_ipack
(
p
,
buf
+
c
,
1
);
c
++
;
p
->
found
++
;
p
->
which
++
;
p
->
hlength
++
;
}
if
(
c
==
count
)
return
count
;
}
p
->
which
=
2000
;
}
void
mpg_set_picture_parameter
(
int32_t
field_type
,
mpg_picture
*
pic
)
{
int16_t
last_h_offset
;
int16_t
last_v_offset
;
}
int16_t
*
p_h_offset
;
int16_t
*
p_v_offset
;
while
(
c
<
count
&&
p
->
found
<
p
->
plength
+
6
){
l
=
count
-
c
;
if
(
l
+
p
->
found
>
p
->
plength
+
6
)
l
=
p
->
plength
+
6
-
p
->
found
;
write_ipack
(
p
,
buf
+
c
,
l
);
p
->
found
+=
l
;
c
+=
l
;
}
if
(
pic
->
mpeg1_flag
){
pic
->
picture_structure
[
field_type
]
=
VIDEO_FRAME_PICTURE
;
pic
->
top_field_first
=
0
;
pic
->
repeat_first_field
=
0
;
pic
->
progressive_frame
=
1
;
pic
->
picture_coding_parameter
=
0x000010
;
break
;
}
/* Reset flag */
pic
->
picture_display_extension_flag
[
field_type
]
=
0
;
last_h_offset
=
pic
->
last_frame_centre_horizontal_offset
;
last_v_offset
=
pic
->
last_frame_centre_vertical_offset
;
if
(
field_type
==
FIRST_FIELD
){
p_h_offset
=
pic
->
frame_centre_horizontal_offset
;
p_v_offset
=
pic
->
frame_centre_vertical_offset
;
*
p_h_offset
=
last_h_offset
;
*
(
p_h_offset
+
1
)
=
last_h_offset
;
*
(
p_h_offset
+
2
)
=
last_h_offset
;
*
p_v_offset
=
last_v_offset
;
*
(
p_v_offset
+
1
)
=
last_v_offset
;
*
(
p_v_offset
+
2
)
=
last_v_offset
;
if
(
p
->
done
){
if
(
p
->
found
+
count
-
c
<
p
->
plength
+
6
){
p
->
found
+=
count
-
c
;
c
=
count
;
}
else
{
pic
->
frame_centre_horizontal_offset
[
3
]
=
last_h_offset
;
pic
->
frame_centre_vertical_offset
[
3
]
=
last_v_offset
;
c
+=
p
->
plength
+
6
-
p
->
found
;
p
->
found
=
p
->
plength
+
6
;
}
}
}
void
init_mpg_picture
(
mpg_picture
*
pic
,
int
chan
,
int32_t
field_type
)
{
pic
->
picture_header
=
0
;
pic
->
sequence_header_data
=
(
INIT_HORIZONTAL_SIZE
<<
20
)
|
(
INIT_VERTICAL_SIZE
<<
8
)
|
(
INIT_ASPECT_RATIO
<<
4
)
|
(
INIT_FRAME_RATE
);
pic
->
mpeg1_flag
=
0
;
pic
->
vinfo
.
horizontal_size
=
INIT_DISP_HORIZONTAL_SIZE
;
pic
->
vinfo
.
vertical_size
=
INIT_DISP_VERTICAL_SIZE
;
pic
->
picture_display_extension_flag
[
field_type
]
=
0
;
pic
->
pts_flag
[
field_type
]
=
0
;
pic
->
sequence_gop_header
=
0
;
pic
->
picture_header
=
0
;
pic
->
sequence_header_flag
=
0
;
pic
->
gop_flag
=
0
;
pic
->
sequence_end_flag
=
0
;
pic
->
sequence_display_extension_flag
=
0
;
pic
->
last_frame_centre_horizontal_offset
=
0
;
pic
->
last_frame_centre_vertical_offset
=
0
;
pic
->
channel
=
chan
;
if
(
p
->
plength
&&
p
->
found
==
p
->
plength
+
6
)
{
send_ipack
(
p
);
dvb_filter_ipack_reset
(
p
);
if
(
c
<
count
)
dvb_filter_instant_repack
(
buf
+
c
,
count
-
c
,
p
);
}
}
return
count
;
}
drivers/media/dvb/dvb-core/dvb_filter.h
View file @
888c9d64
...
...
@@ -6,18 +6,18 @@
#include "demux.h"
typedef
int
(
pes2ts_cb_t
)
(
void
*
,
unsigned
char
*
);
typedef
int
(
dvb_filter_
pes2ts_cb_t
)
(
void
*
,
unsigned
char
*
);
typedef
struct
pes2ts_s
{
typedef
struct
dvb_filter_
pes2ts_s
{
unsigned
char
buf
[
188
];
unsigned
char
cc
;
pes2ts_cb_t
*
cb
;
dvb_filter_
pes2ts_cb_t
*
cb
;
void
*
priv
;
}
pes2ts_t
;
}
dvb_filter_
pes2ts_t
;
void
pes2ts_init
(
pes2ts_t
*
p2ts
,
unsigned
short
pid
,
pes2ts_cb_t
*
cb
,
void
*
priv
);
int
pes2ts
(
pes2ts_t
*
p2ts
,
unsigned
char
*
pes
,
int
len
);
void
dvb_filter_pes2ts_init
(
dvb_filter_
pes2ts_t
*
p2ts
,
unsigned
short
pid
,
dvb_filter_
pes2ts_cb_t
*
cb
,
void
*
priv
);
int
dvb_filter_pes2ts
(
dvb_filter_
pes2ts_t
*
p2ts
,
unsigned
char
*
pes
,
int
len
);
#define PROG_STREAM_MAP 0xBC
...
...
@@ -224,26 +224,11 @@ typedef struct audio_i{
}
AudioInfo
;
void
reset_ipack
(
ipack
*
p
);
int
instant_repack
(
u8
*
buf
,
int
count
,
ipack
*
p
);
void
init_ipack
(
ipack
*
p
,
int
size
,
void
dvb_filter_ipack_reset
(
ipack
*
p
);
int
dvb_filter_
instant_repack
(
u8
*
buf
,
int
count
,
ipack
*
p
);
void
dvb_filter_ipack_init
(
ipack
*
p
,
int
size
,
void
(
*
func
)(
u8
*
buf
,
int
size
,
void
*
priv
));
void
free_ipack
(
ipack
*
p
);
void
setup_ts2pes
(
ipack
*
pa
,
ipack
*
pv
,
u16
*
pida
,
u16
*
pidv
,
void
(
*
pes_write
)(
u8
*
buf
,
int
count
,
void
*
data
),
void
*
priv
);
void
ts_to_pes
(
ipack
*
p
,
u8
*
buf
);
void
send_ipack
(
ipack
*
p
);
void
send_ipack_rest
(
ipack
*
p
);
int
get_ainfo
(
uint8_t
*
mbuf
,
int
count
,
AudioInfo
*
ai
,
int
pr
);
int
get_ac3info
(
uint8_t
*
mbuf
,
int
count
,
AudioInfo
*
ai
,
int
pr
);
int
get_vinfo
(
uint8_t
*
mbuf
,
int
count
,
VideoInfo
*
vi
,
int
pr
);
uint8_t
*
skip_pes_header
(
uint8_t
**
bufp
);
void
initialize_quant_matrix
(
uint32_t
*
matrix
);
void
initialize_mpg_picture
(
mpg_picture
*
pic
);
void
init_mpg_picture
(
mpg_picture
*
pic
,
int
chan
,
int32_t
field_type
);
void
mpg_set_picture_parameter
(
int32_t
field_type
,
mpg_picture
*
pic
);
int
read_sequence_header
(
uint8_t
*
headr
,
VideoInfo
*
vi
,
int
pr
);
int
read_gop_header
(
uint8_t
*
headr
,
mpg_picture
*
pic
,
int
pr
);
int
read_picture_header
(
uint8_t
*
headr
,
mpg_picture
*
pic
,
int
field
,
int
pr
);
void
dvb_filter_ipack_free
(
ipack
*
p
);
void
dvb_filter_ipack_flush
(
ipack
*
p
);
#endif
drivers/media/dvb/dvb-core/dvb_frontend.c
View file @
888c9d64
...
...
@@ -83,7 +83,7 @@ struct dvb_frontend_data {
struct
dvb_frontend_ioctl_data
{
struct
list_head
list_head
;
struct
dvb_adapter
_s
*
adapter
;
struct
dvb_adapter
*
adapter
;
int
(
*
before_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
);
int
(
*
after_ioctl
)
(
struct
dvb_frontend
*
frontend
,
...
...
@@ -336,9 +336,6 @@ int dvb_frontend_set_parameters (struct dvb_frontend_data *fe,
struct
dvb_frontend
*
frontend
=
&
fe
->
frontend
;
int
err
;
dprintk
(
"%s: f == %i, drift == %i
\n
"
,
__FUNCTION__
,
param
->
frequency
,
fe
->
lnb_drift
);
dvb_bend_frequency
(
fe
,
0
);
if
(
first_trial
)
{
...
...
@@ -352,6 +349,9 @@ int dvb_frontend_set_parameters (struct dvb_frontend_data *fe,
sizeof
(
struct
dvb_frontend_parameters
));
}
dprintk
(
"%s: f == %i, drift == %i
\n
"
,
__FUNCTION__
,
param
->
frequency
,
fe
->
lnb_drift
);
param
->
frequency
+=
fe
->
lnb_drift
+
fe
->
bending
;
err
=
dvb_frontend_internal_ioctl
(
frontend
,
FE_SET_FRONTEND
,
param
);
param
->
frequency
-=
fe
->
lnb_drift
+
fe
->
bending
;
...
...
@@ -367,9 +367,8 @@ void dvb_frontend_init (struct dvb_frontend_data *fe)
struct
dvb_frontend
*
frontend
=
&
fe
->
frontend
;
struct
dvb_frontend_parameters
*
init_param
;
printk
(
"%s: initialising frontend %i:%i (%s)...
\n
"
,
__FUNCTION__
,
frontend
->
i2c
->
adapter
->
num
,
frontend
->
i2c
->
id
,
fe
->
info
->
name
);
printk
(
"DVB: initialising frontend %i:%i (%s)...
\n
"
,
frontend
->
i2c
->
adapter
->
num
,
frontend
->
i2c
->
id
,
fe
->
info
->
name
);
dvb_frontend_internal_ioctl
(
frontend
,
FE_INIT
,
NULL
);
...
...
@@ -436,15 +435,20 @@ void dvb_frontend_recover (struct dvb_frontend_data *fe)
*/
{
int
j
=
fe
->
lost_sync_count
;
int
stepsize
=
fe
->
info
->
frequency_stepsize
;
if
(
j
%
32
==
0
)
fe
->
lnb_drift
=
0
;
int
stepsize
;
if
(
j
%
2
)
fe
->
lnb_drift
+=
stepsize
*
((
j
+
1
)
/
2
)
;
if
(
fe
->
info
->
type
==
FE_QPSK
)
stepsize
=
fe
->
parameters
.
u
.
qpsk
.
symbol_rate
/
16000
;
else
stepsize
=
fe
->
info
->
frequency_stepsize
*
2
;
if
(
j
%
32
==
0
)
{
fe
->
lnb_drift
=
0
;
}
else
{
fe
->
lnb_drift
=
-
fe
->
lnb_drift
;
if
(
j
%
2
)
fe
->
lnb_drift
+=
stepsize
;
}
dvb_frontend_set_parameters
(
fe
,
&
fe
->
parameters
,
0
);
}
...
...
@@ -511,7 +515,8 @@ int dvb_frontend_thread (void *data)
fe
->
lost_sync_count
=
0
;
}
else
{
fe
->
lost_sync_count
++
;
if
(
fe
->
lost_sync_count
<
10
)
/* XXX FIXME CHECKME! */
continue
;
dvb_frontend_recover
(
fe
);
delay
=
HZ
/
5
;
if
(
jiffies
-
fe
->
lost_sync_jiffies
>
TIMEOUT
)
{
...
...
@@ -627,7 +632,7 @@ unsigned int dvb_frontend_poll (struct file *file, struct poll_table_struct *wai
static
int
dvb_frontend_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
file
->
private_data
;
struct
dvb_frontend_data
*
fe
=
dvbdev
->
priv
;
int
ret
;
...
...
@@ -648,7 +653,7 @@ int dvb_frontend_open (struct inode *inode, struct file *file)
static
int
dvb_frontend_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
file
->
private_data
;
struct
dvb_frontend_data
*
fe
=
dvbdev
->
priv
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
...
...
@@ -661,7 +666,7 @@ int dvb_frontend_release (struct inode *inode, struct file *file)
int
dvb_add_frontend_ioctls
(
struct
dvb_adapter
_s
*
adapter
,
dvb_add_frontend_ioctls
(
struct
dvb_adapter
*
adapter
,
int
(
*
before_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
),
int
(
*
after_ioctl
)
(
struct
dvb_frontend
*
frontend
,
...
...
@@ -715,7 +720,7 @@ dvb_add_frontend_ioctls (struct dvb_adapter_s *adapter,
void
dvb_remove_frontend_ioctls
(
struct
dvb_adapter
_s
*
adapter
,
dvb_remove_frontend_ioctls
(
struct
dvb_adapter
*
adapter
,
int
(
*
before_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
),
int
(
*
after_ioctl
)
(
struct
dvb_frontend
*
frontend
,
...
...
@@ -748,7 +753,7 @@ dvb_remove_frontend_ioctls (struct dvb_adapter_s *adapter,
int
dvb_add_frontend_notifier
(
struct
dvb_adapter
_s
*
adapter
,
dvb_add_frontend_notifier
(
struct
dvb_adapter
*
adapter
,
void
(
*
callback
)
(
fe_status_t
s
,
void
*
data
),
void
*
data
)
{
...
...
@@ -791,7 +796,7 @@ dvb_add_frontend_notifier (struct dvb_adapter_s *adapter,
void
dvb_remove_frontend_notifier
(
struct
dvb_adapter
_s
*
adapter
,
dvb_remove_frontend_notifier
(
struct
dvb_adapter
*
adapter
,
void
(
*
callback
)
(
fe_status_t
s
,
void
*
data
))
{
struct
list_head
*
entry
;
...
...
@@ -827,11 +832,11 @@ dvb_remove_frontend_notifier (struct dvb_adapter_s *adapter,
static
struct
file_operations
dvb_frontend_fops
=
{
owner:
THIS_MODULE
,
ioctl:
dvb_generic_ioctl
,
poll:
dvb_frontend_poll
,
open:
dvb_frontend_open
,
release:
dvb_frontend_release
.
owner
=
THIS_MODULE
,
.
ioctl
=
dvb_generic_ioctl
,
.
poll
=
dvb_frontend_poll
,
.
open
=
dvb_frontend_open
,
.
release
=
dvb_frontend_release
};
...
...
@@ -845,9 +850,11 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
{
struct
list_head
*
entry
;
struct
dvb_frontend_data
*
fe
;
dvb_device_t
dvbdev_template
=
{
users
:
1
,
writers
:
1
,
fops:
&
dvb_frontend_fops
,
kernel_ioctl:
dvb_frontend_ioctl
static
const
struct
dvb_device
dvbdev_template
=
{
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_frontend_fops
,
.
kernel_ioctl
=
dvb_frontend_ioctl
};
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
...
...
@@ -878,7 +885,9 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
list_for_each
(
entry
,
&
frontend_ioctl_list
)
{
struct
dvb_frontend_ioctl_data
*
ioctl
;
ioctl
=
list_entry
(
entry
,
struct
dvb_frontend_ioctl_data
,
list_head
);
ioctl
=
list_entry
(
entry
,
struct
dvb_frontend_ioctl_data
,
list_head
);
if
(
ioctl
->
adapter
==
i2c
->
adapter
)
{
fe
->
frontend
.
before_ioctl
=
ioctl
->
before_ioctl
;
...
...
@@ -936,3 +945,4 @@ MODULE_PARM(dvb_frontend_debug,"i");
MODULE_PARM
(
dvb_shutdown_timeout
,
"i"
);
MODULE_PARM_DESC
(
dvb_frontend_debug
,
"enable verbose debug messages"
);
MODULE_PARM_DESC
(
dvb_shutdown_timeout
,
"wait <shutdown_timeout> seconds after close() before suspending hardware"
);
drivers/media/dvb/dvb-core/dvb_frontend.h
View file @
888c9d64
...
...
@@ -90,7 +90,7 @@ dvb_unregister_frontend (int (*ioctl) (struct dvb_frontend *frontend,
* Return value: number of frontends where the ioctl's were applied.
*/
extern
int
dvb_add_frontend_ioctls
(
struct
dvb_adapter
_s
*
adapter
,
dvb_add_frontend_ioctls
(
struct
dvb_adapter
*
adapter
,
int
(
*
before_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
),
int
(
*
after_ioctl
)
(
struct
dvb_frontend
*
frontend
,
...
...
@@ -99,18 +99,18 @@ dvb_add_frontend_ioctls (struct dvb_adapter_s *adapter,
extern
void
dvb_remove_frontend_ioctls
(
struct
dvb_adapter
_s
*
adapter
,
dvb_remove_frontend_ioctls
(
struct
dvb_adapter
*
adapter
,
int
(
*
before_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
),
int
(
*
after_ioctl
)
(
struct
dvb_frontend
*
frontend
,
unsigned
int
cmd
,
void
*
arg
));
extern
int
dvb_add_frontend_notifier
(
struct
dvb_adapter
_s
*
adapter
,
dvb_add_frontend_notifier
(
struct
dvb_adapter
*
adapter
,
void
(
*
callback
)
(
fe_status_t
s
,
void
*
data
),
void
*
data
);
extern
void
dvb_remove_frontend_notifier
(
struct
dvb_adapter
_s
*
adapter
,
dvb_remove_frontend_notifier
(
struct
dvb_adapter
*
adapter
,
void
(
*
callback
)
(
fe_status_t
s
,
void
*
data
));
#endif
...
...
drivers/media/dvb/dvb-core/dvb_i2c.c
View file @
888c9d64
...
...
@@ -173,7 +173,7 @@ struct dvb_i2c_bus*
dvb_register_i2c_bus
(
int
(
*
xfer
)
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
),
void
*
data
,
struct
dvb_adapter
_s
*
adapter
,
struct
dvb_adapter
*
adapter
,
int
id
)
{
struct
dvb_i2c_bus
*
i2c
;
...
...
@@ -200,7 +200,7 @@ dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct
dvb_i2c_bus
*
dvb_find_i2c_bus
(
int
(
*
xfer
)
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
),
struct
dvb_adapter
_s
*
adapter
,
struct
dvb_adapter
*
adapter
,
int
id
)
{
struct
list_head
*
entry
;
...
...
@@ -231,7 +231,7 @@ dvb_find_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
void
dvb_unregister_i2c_bus
(
int
(
*
xfer
)
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
),
struct
dvb_adapter
_s
*
adapter
,
struct
dvb_adapter
*
adapter
,
int
id
)
{
struct
dvb_i2c_bus
*
i2c
=
dvb_find_i2c_bus
(
xfer
,
adapter
,
id
);
...
...
drivers/media/dvb/dvb-core/dvb_i2c.h
View file @
888c9d64
...
...
@@ -32,7 +32,7 @@ struct dvb_i2c_bus {
struct
list_head
list_head
;
int
(
*
xfer
)
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
);
void
*
data
;
struct
dvb_adapter
_s
*
adapter
;
struct
dvb_adapter
*
adapter
;
int
id
;
struct
list_head
client_list
;
};
...
...
@@ -43,13 +43,13 @@ struct dvb_i2c_bus* dvb_register_i2c_bus (int (*xfer) (struct dvb_i2c_bus *i2c,
struct
i2c_msg
msgs
[],
int
num
),
void
*
data
,
struct
dvb_adapter
_s
*
adapter
,
struct
dvb_adapter
*
adapter
,
int
id
);
extern
void
dvb_unregister_i2c_bus
(
int
(
*
xfer
)
(
struct
dvb_i2c_bus
*
i2c
,
struct
i2c_msg
msgs
[],
int
num
),
struct
dvb_adapter
_s
*
adapter
,
struct
dvb_adapter
*
adapter
,
int
id
);
...
...
drivers/media/dvb/dvb-core/dvb_ksyms.c
View file @
888c9d64
...
...
@@ -9,11 +9,12 @@
#include "dvb_net.h"
EXPORT_SYMBOL
(
DmxDevInit
);
EXPORT_SYMBOL
(
DmxDevRelease
);
EXPORT_SYMBOL
(
DvbDmxInit
);
EXPORT_SYMBOL
(
DvbDmxRelease
);
EXPORT_SYMBOL
(
DvbDmxSWFilterPackets
);
EXPORT_SYMBOL
(
dvb_dmxdev_init
);
EXPORT_SYMBOL
(
dvb_dmxdev_release
);
EXPORT_SYMBOL
(
dvb_dmx_init
);
EXPORT_SYMBOL
(
dvb_dmx_release
);
EXPORT_SYMBOL
(
dvb_dmx_swfilter_packet
);
EXPORT_SYMBOL
(
dvb_dmx_swfilter_packets
);
EXPORT_SYMBOL
(
dvb_register_frontend
);
EXPORT_SYMBOL
(
dvb_unregister_frontend
);
...
...
@@ -37,13 +38,12 @@ EXPORT_SYMBOL(dvb_unregister_device);
EXPORT_SYMBOL
(
dvb_generic_ioctl
);
EXPORT_SYMBOL
(
dvb_generic_open
);
EXPORT_SYMBOL
(
dvb_generic_release
);
EXPORT_SYMBOL
(
generic_usercopy
);
EXPORT_SYMBOL
(
init_ipack
);
EXPORT_SYMBOL
(
reset_ipack
);
EXPORT_SYMBOL
(
free_ipack
);
EXPORT_SYMBOL
(
send_ipack_rest
);
EXPORT_SYMBOL
(
instant_repack
);
EXPORT_SYMBOL
(
pes2ts_init
);
EXPORT_SYMBOL
(
pes2ts
);
EXPORT_SYMBOL
(
dvb_filter_ipack_init
);
EXPORT_SYMBOL
(
dvb_filter_ipack_reset
);
EXPORT_SYMBOL
(
dvb_filter_ipack_free
);
EXPORT_SYMBOL
(
dvb_filter_ipack_flush
);
EXPORT_SYMBOL
(
dvb_filter_instant_repack
);
EXPORT_SYMBOL
(
dvb_filter_pes2ts_init
);
EXPORT_SYMBOL
(
dvb_filter_pes2ts
);
drivers/media/dvb/dvb-core/dvb_net.c
View file @
888c9d64
...
...
@@ -435,7 +435,7 @@ dvb_net_remove_if(dvb_net_t *dvbnet, int num)
int
dvb_net_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
parg
)
{
dvb_device_t
*
dvbdev
=
(
dvb_device_t
*
)
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
(
struct
dvb_device
*
)
file
->
private_data
;
dvb_net_t
*
dvbnet
=
(
dvb_net_t
*
)
dvbdev
->
priv
;
if
(((
file
->
f_flags
&
O_ACCMODE
)
==
O_RDONLY
))
...
...
@@ -462,21 +462,18 @@ int dvb_net_ioctl(struct inode *inode, struct file *file,
}
static
struct
file_operations
dvb_net_fops
=
{
owner:
THIS_MODULE
,
read:
0
,
write:
0
,
ioctl:
dvb_generic_ioctl
,
open:
dvb_generic_open
,
release:
dvb_generic_release
,
poll:
0
,
.
owner
=
THIS_MODULE
,
.
ioctl
=
dvb_generic_ioctl
,
.
open
=
dvb_generic_open
,
.
release
=
dvb_generic_release
,
};
static
dvb_device_t
dvbdev_net
=
{
priv:
0
,
users:
1
,
writers:
1
,
fops:
&
dvb_net_fops
,
kernel_ioctl:
dvb_net_ioctl
,
static
struct
dvb_device
dvbdev_net
=
{
.
priv
=
0
,
.
users
=
1
,
.
writers
=
1
,
.
fops
=
&
dvb_net_fops
,
.
kernel_ioctl
=
dvb_net_ioctl
,
};
void
...
...
@@ -493,7 +490,7 @@ dvb_net_release(dvb_net_t *dvbnet)
}
int
dvb_net_init
(
dvb_adapter_t
*
adap
,
dvb_net_t
*
dvbnet
,
dmx_demux_t
*
demux
)
dvb_net_init
(
struct
dvb_adapter
*
adap
,
dvb_net_t
*
dvbnet
,
dmx_demux_t
*
demux
)
{
int
i
;
...
...
drivers/media/dvb/dvb-core/dvb_net.h
View file @
888c9d64
...
...
@@ -47,7 +47,7 @@ typedef struct dvb_net_priv_s {
}
dvb_net_priv_t
;
typedef
struct
dvb_net_s
{
dvb_device_t
*
dvbdev
;
struct
dvb_device
*
dvbdev
;
int
card_num
;
int
dev_num
;
...
...
@@ -58,6 +58,6 @@ typedef struct dvb_net_s {
void
dvb_net_release
(
dvb_net_t
*
);
int
dvb_net_init
(
dvb_adapter_t
*
,
dvb_net_t
*
,
dmx_demux_t
*
);
int
dvb_net_init
(
struct
dvb_adapter
*
,
dvb_net_t
*
,
dmx_demux_t
*
);
#endif
drivers/media/dvb/dvb-core/dvbdev.c
View file @
888c9d64
...
...
@@ -37,6 +37,7 @@
#include <asm/system.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/videodev.h>
#include "compat.h"
#include "dvbdev.h"
...
...
@@ -69,17 +70,17 @@ static char *dnames[] = {
static
dvb_device_t
*
dvbdev_find_device
(
int
minor
)
struct
dvb_device
*
dvbdev_find_device
(
int
minor
)
{
struct
list_head
*
entry
;
list_for_each
(
entry
,
&
dvb_adapter_list
)
{
struct
list_head
*
entry0
;
dvb_adapter_t
*
adap
;
adap
=
list_entry
(
entry
,
dvb_adapter_t
,
list_head
);
struct
dvb_adapter
*
adap
;
adap
=
list_entry
(
entry
,
struct
dvb_adapter
,
list_head
);
list_for_each
(
entry0
,
&
adap
->
device_list
)
{
dvb_device_t
*
dev
;
dev
=
list_entry
(
entry0
,
dvb_device_t
,
list_head
);
struct
dvb_device
*
dev
;
dev
=
list_entry
(
entry0
,
struct
dvb_device
,
list_head
);
if
(
nums2minor
(
adap
->
num
,
dev
->
type
,
dev
->
id
)
==
minor
)
return
dev
;
}
...
...
@@ -92,7 +93,7 @@ dvb_device_t* dvbdev_find_device (int minor)
static
int
dvb_device_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
;
struct
dvb_device
*
dvbdev
;
dvbdev
=
dvbdev_find_device
(
minor
(
inode
->
i_rdev
));
...
...
@@ -118,13 +119,8 @@ int dvb_device_open(struct inode *inode, struct file *file)
static
struct
file_operations
dvb_device_fops
=
{
owner:
THIS_MODULE
,
read:
NULL
,
write:
NULL
,
ioctl:
NULL
,
open:
dvb_device_open
,
release:
NULL
,
poll:
NULL
,
.
owner
=
THIS_MODULE
,
.
open
=
dvb_device_open
,
};
#endif
/* CONFIG_DVB_DEVFS_ONLY */
...
...
@@ -132,7 +128,7 @@ static struct file_operations dvb_device_fops =
int
dvb_generic_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
file
->
private_data
;
if
(
!
dvbdev
)
return
-
ENODEV
;
...
...
@@ -153,7 +149,7 @@ int dvb_generic_open(struct inode *inode, struct file *file)
int
dvb_generic_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
dvb_device_t
*
dvbdev
=
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
file
->
private_data
;
if
(
!
dvbdev
)
return
-
ENODEV
;
...
...
@@ -166,73 +162,10 @@ int dvb_generic_release(struct inode *inode, struct file *file)
}
/*
* helper function -- handles userspace copying for ioctl arguments
*/
int
generic_usercopy
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
,
int
(
*
func
)(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
arg
))
{
char
sbuf
[
128
];
void
*
mbuf
=
NULL
;
void
*
parg
=
NULL
;
int
err
=
-
EINVAL
;
/* Copy arguments into temp kernel buffer */
switch
(
_IOC_DIR
(
cmd
))
{
case
_IOC_NONE
:
parg
=
(
void
*
)
arg
;
break
;
case
_IOC_READ
:
/* some v4l ioctls are marked wrong ... */
case
_IOC_WRITE
:
case
(
_IOC_WRITE
|
_IOC_READ
):
if
(
_IOC_SIZE
(
cmd
)
<=
sizeof
(
sbuf
))
{
parg
=
sbuf
;
}
else
{
/* too big to allocate from stack */
mbuf
=
kmalloc
(
_IOC_SIZE
(
cmd
),
GFP_KERNEL
);
if
(
NULL
==
mbuf
)
return
-
ENOMEM
;
parg
=
mbuf
;
}
err
=
-
EFAULT
;
if
(
copy_from_user
(
parg
,
(
void
*
)
arg
,
_IOC_SIZE
(
cmd
)))
goto
out
;
break
;
}
/* call driver */
if
((
err
=
func
(
inode
,
file
,
cmd
,
parg
))
==
-
ENOIOCTLCMD
)
err
=
-
EINVAL
;
if
(
err
<
0
)
goto
out
;
/* Copy results into user buffer */
switch
(
_IOC_DIR
(
cmd
))
{
case
_IOC_READ
:
case
(
_IOC_WRITE
|
_IOC_READ
):
if
(
copy_to_user
((
void
*
)
arg
,
parg
,
_IOC_SIZE
(
cmd
)))
err
=
-
EFAULT
;
break
;
}
out:
if
(
mbuf
)
kfree
(
mbuf
);
return
err
;
}
int
dvb_generic_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
dvb_device_t
*
dvbdev
=
file
->
private_data
;
struct
dvb_device
*
dvbdev
=
file
->
private_data
;
if
(
!
dvbdev
)
return
-
ENODEV
;
...
...
@@ -240,20 +173,20 @@ int dvb_generic_ioctl(struct inode *inode, struct file *file,
if
(
!
dvbdev
->
kernel_ioctl
)
return
-
EINVAL
;
return
generic
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvbdev
->
kernel_ioctl
);
return
video
_usercopy
(
inode
,
file
,
cmd
,
arg
,
dvbdev
->
kernel_ioctl
);
}
static
int
dvbdev_get_free_id
(
struct
dvb_adapter
_s
*
adap
,
int
type
)
int
dvbdev_get_free_id
(
struct
dvb_adapter
*
adap
,
int
type
)
{
u32
id
=
0
;
while
(
id
<
DVB_MAX_IDS
)
{
struct
list_head
*
entry
;
list_for_each
(
entry
,
&
adap
->
device_list
)
{
dvb_device_t
*
dev
;
dev
=
list_entry
(
entry
,
dvb_device_t
,
list_head
);
struct
dvb_device
*
dev
;
dev
=
list_entry
(
entry
,
struct
dvb_device
,
list_head
);
if
(
dev
->
type
==
type
&&
dev
->
id
==
id
)
goto
skip
;
}
...
...
@@ -265,12 +198,12 @@ int dvbdev_get_free_id (struct dvb_adapter_s *adap, int type)
}
int
dvb_register_device
(
dvb_adapter_t
*
adap
,
dvb_device_t
**
pdvbdev
,
dvb_device_t
*
template
,
void
*
priv
,
int
type
)
int
dvb_register_device
(
struct
dvb_adapter
*
adap
,
struct
dvb_device
**
pdvbdev
,
const
struct
dvb_device
*
template
,
void
*
priv
,
int
type
)
{
u32
id
;
char
name
[
20
];
dvb_device_t
*
dvbdev
;
struct
dvb_device
*
dvbdev
;
if
(
down_interruptible
(
&
dvbdev_register_lock
))
return
-
ERESTARTSYS
;
...
...
@@ -282,7 +215,7 @@ int dvb_register_device(dvb_adapter_t *adap, dvb_device_t **pdvbdev,
return
-
ENFILE
;
}
*
pdvbdev
=
dvbdev
=
kmalloc
(
sizeof
(
dvb_device_t
),
GFP_KERNEL
);
*
pdvbdev
=
dvbdev
=
kmalloc
(
sizeof
(
struct
dvb_device
),
GFP_KERNEL
);
if
(
!
dvbdev
)
{
up
(
&
dvbdev_register_lock
);
...
...
@@ -291,7 +224,7 @@ int dvb_register_device(dvb_adapter_t *adap, dvb_device_t **pdvbdev,
up
(
&
dvbdev_register_lock
);
memcpy
(
dvbdev
,
template
,
sizeof
(
dvb_device_t
));
memcpy
(
dvbdev
,
template
,
sizeof
(
struct
dvb_device
));
dvbdev
->
type
=
type
;
dvbdev
->
id
=
id
;
dvbdev
->
adapter
=
adap
;
...
...
@@ -307,15 +240,15 @@ int dvb_register_device(dvb_adapter_t *adap, dvb_device_t **pdvbdev,
S_IFCHR
|
S_IRUSR
|
S_IWUSR
,
dvbdev
->
fops
,
dvbdev
);
dprintk
(
"
%s: register adapter%d/%s @ minor: %i (0x%02x) - dvbdev: %p
\n
"
,
__FUNCTION__
,
adap
->
num
,
name
,
nums2minor
(
adap
->
num
,
type
,
id
),
nums2minor
(
adap
->
num
,
type
,
id
)
,
dvbdev
);
dprintk
(
"
DVB: register adapter%d/%s @ minor: %i (0x%02x)
\n
"
,
adap
->
num
,
name
,
nums2minor
(
adap
->
num
,
type
,
id
),
nums2minor
(
adap
->
num
,
type
,
id
));
return
0
;
}
void
dvb_unregister_device
(
dvb_device_t
*
dvbdev
)
void
dvb_unregister_device
(
struct
dvb_device
*
dvbdev
)
{
if
(
!
dvbdev
)
return
;
...
...
@@ -334,8 +267,8 @@ int dvbdev_get_free_adapter_num (void)
while
(
1
)
{
struct
list_head
*
entry
;
list_for_each
(
entry
,
&
dvb_adapter_list
)
{
dvb_adapter_t
*
adap
;
adap
=
list_entry
(
entry
,
dvb_adapter_t
,
list_head
);
struct
dvb_adapter
*
adap
;
adap
=
list_entry
(
entry
,
struct
dvb_adapter
,
list_head
);
if
(
adap
->
num
==
num
)
goto
skip
;
}
...
...
@@ -348,10 +281,10 @@ int dvbdev_get_free_adapter_num (void)
}
int
dvb_register_adapter
(
dvb_adapter_t
**
padap
,
char
*
name
)
int
dvb_register_adapter
(
struct
dvb_adapter
**
padap
,
char
*
name
)
{
char
dirname
[
16
];
dvb_adapter_t
*
adap
;
struct
dvb_adapter
*
adap
;
int
num
;
if
(
down_interruptible
(
&
dvbdev_register_lock
))
...
...
@@ -362,17 +295,17 @@ int dvb_register_adapter(dvb_adapter_t **padap, char *name)
return
-
ENFILE
;
}
if
(
!
(
*
padap
=
adap
=
kmalloc
(
sizeof
(
dvb_adapter_t
),
GFP_KERNEL
)))
{
if
(
!
(
*
padap
=
adap
=
kmalloc
(
sizeof
(
struct
dvb_adapter
),
GFP_KERNEL
)))
{
up
(
&
dvbdev_register_lock
);
return
-
ENOMEM
;
}
memset
(
adap
,
0
,
sizeof
(
dvb_adapter_t
));
memset
(
adap
,
0
,
sizeof
(
struct
dvb_adapter
));
INIT_LIST_HEAD
(
&
adap
->
device_list
);
MOD_INC_USE_COUNT
;
printk
(
"
%s: registering new adapter (%s).
\n
"
,
__FUNCTION__
,
name
);
printk
(
"
DVB: registering new adapter (%s).
\n
"
,
name
);
sprintf
(
dirname
,
"dvb/adapter%d"
,
num
);
adap
->
devfs_handle
=
devfs_mk_dir
(
NULL
,
dirname
,
NULL
);
...
...
@@ -386,7 +319,7 @@ int dvb_register_adapter(dvb_adapter_t **padap, char *name)
}
int
dvb_unregister_adapter
(
dvb_adapter_t
*
adap
)
int
dvb_unregister_adapter
(
struct
dvb_adapter
*
adap
)
{
devfs_unregister
(
adap
->
devfs_handle
);
if
(
down_interruptible
(
&
dvbdev_register_lock
))
...
...
drivers/media/dvb/dvb-core/dvbdev.h
View file @
888c9d64
...
...
@@ -43,49 +43,48 @@
#define DVB_DEVICE_OSD 8
typedef
struct
dvb_adapter_s
{
struct
dvb_adapter
{
int
num
;
devfs_handle_t
devfs_handle
;
struct
list_head
list_head
;
struct
list_head
device_list
;
}
dvb_adapter_t
;
};
typedef
struct
dvb_device
{
struct
dvb_device
{
struct
list_head
list_head
;
struct
file_operations
*
fops
;
devfs_handle_t
devfs_handle
;
dvb_adapter_t
*
adapter
;
struct
dvb_adapter
*
adapter
;
int
type
;
u32
id
;
int
users
;
int
writers
;
/* don't really need those !?
*/
/* don't really need those !? -- FIXME: use video_usercopy
*/
int
(
*
kernel_ioctl
)(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
arg
);
// FIXME: use generic_usercopy()
unsigned
int
cmd
,
void
*
arg
);
void
*
priv
;
}
dvb_device_t
;
};
int
dvb_register_device
(
dvb_adapter_t
*
adap
,
dvb_device_t
**
pdvbdev
,
dvb_device_t
*
template
,
void
*
priv
,
int
type
);
void
dvb_unregister_device
(
struct
dvb_device
*
dvbdev
);
extern
int
dvb_register_adapter
(
struct
dvb_adapter
**
padap
,
char
*
name
);
extern
int
dvb_unregister_adapter
(
struct
dvb_adapter
*
adap
);
int
dvb_register_adapter
(
dvb_adapter_t
**
padap
,
char
*
name
);
int
dvb_unregister_adapter
(
dvb_adapter_t
*
adap
);
extern
int
dvb_register_device
(
struct
dvb_adapter
*
adap
,
struct
dvb_device
**
pdvbdev
,
const
struct
dvb_device
*
template
,
void
*
priv
,
int
type
);
int
dvb_generic_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
extern
void
dvb_unregister_device
(
struct
dvb_device
*
dvbdev
);
extern
int
dvb_generic_open
(
struct
inode
*
inode
,
struct
file
*
file
);
extern
int
dvb_generic_release
(
struct
inode
*
inode
,
struct
file
*
file
);
extern
int
dvb_generic_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
);
int
dvb_generic_open
(
struct
inode
*
inode
,
struct
file
*
file
);
int
dvb_generic_release
(
struct
inode
*
inode
,
struct
file
*
file
);
int
generic_usercopy
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
unsigned
long
arg
,
int
(
*
func
)(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
arg
));
#endif
/* #ifndef __DVBDEV_H */
#endif
/* #ifndef _DVBDEV_H_ */
drivers/media/dvb/frontends/Kconfig
View file @
888c9d64
...
...
@@ -23,6 +23,30 @@ config DVB_ALPS_BSRV2
DVB adapter simply enable all supported frontends, the
right one will get autodetected.
config DVB_ALPS_TDLB7
tristate "Alps TDLB7 (OFDM)"
depends on DVB_CORE
help
A DVB-T tuner module. Say Y when you want to support this frontend.
This tuner module needs some microcode located in a file called
"Sc_main.mc" in the windows driver. Please pass the module parameter
mcfile="/PATH/FILENAME" when loading alps_tdlb7.o.
If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the
right one will get autodetected.
config DVB_ALPS_TDMB7
tristate "Alps BSRV2 (OFDM)"
depends on DVB_CORE
help
A DVB-S tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the
right one will get autodetected.
config DVB_GRUNDIG_29504_491
tristate "Grundig 29504-491 (QPSK)"
depends on DVB_CORE
...
...
drivers/media/dvb/frontends/Makefile
View file @
888c9d64
...
...
@@ -6,6 +6,8 @@ EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
obj-$(CONFIG_DVB_ALPS_BSRU6)
+=
alps_bsru6.o
obj-$(CONFIG_DVB_ALPS_BSRV2)
+=
alps_bsrv2.o
obj-$(CONFIG_DVB_ALPS_TDLB7)
+=
alps_tdlb7.o
obj-$(CONFIG_DVB_ALPS_TDMB7)
+=
alps_tdmb7.o
obj-$(CONFIG_DVB_GRUNDIG_29504_491)
+=
grundig_29504-491.o
obj-$(CONFIG_DVB_GRUNDIG_29504_401)
+=
grundig_29504-401.o
obj-$(CONFIG_DVB_VES1820)
+=
ves1820.o
...
...
drivers/media/dvb/frontends/alps_bsru6.c
View file @
888c9d64
/*
Alps BSRU6 DVB QPSK frontend driver
Alps BSRU6
and LG TDQB-S00x
DVB QPSK frontend driver
Copyright (C) 2001-2002 Convergence Integrated Media GmbH
<ralph@convergence.de>, <holger@convergence.de>
<ralph@convergence.de>, <holger@convergence.de>,
<js@convergence.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -32,12 +33,16 @@ static int debug = 0;
#define M_CLK (88000000UL)
/* M=21, K=0, P=0, f_VCO = 4MHz*4*(M+1)/(K+1) = 352 MHz */
static
struct
dvb_frontend_info
bsru6_info
=
{
#ifdef CONFIG_ALPS_BSRU6_IS_LG_TDQBS00X
name:
"LG TDQB-S00x"
,
#else
name:
"Alps BSRU6"
,
#endif
type:
FE_QPSK
,
frequency_min:
950000
,
frequency_max:
2150000
,
...
...
@@ -63,7 +68,8 @@ u8 init_tab [] = {
0x05
,
0x35
,
// SDAT:0 SCLT:0 I2CT:1
0x06
,
0x00
,
// DAC mode and MSB
0x07
,
0x00
,
// DAC LSB
0x08
,
0x43
,
// DiSEqC
// 0x08, 0x43, // DiSEqC
0x08
,
0x03
,
// DiSEqC
0x09
,
0x00
,
0x0a
,
0x42
,
0x0c
,
0x51
,
// QPSK reverse:1 Nyquist:0 OP0 val:1 OP0 con:1 OP1 val:1 OP1 con:1
...
...
@@ -79,17 +85,20 @@ u8 init_tab [] = {
0x15
,
0xc9
,
// lock detector threshold
0x16
,
0x1d
,
0x17
,
0x0
,
0x17
,
0x0
0
,
0x18
,
0x14
,
0x19
,
0xf2
,
0x1a
,
0x11
,
0x1b
,
0x9c
,
0x1c
,
0x0
,
0x1d
,
0x0
,
0x1e
,
0xb
,
0x1c
,
0x00
,
0x1d
,
0x00
,
0x1e
,
0x0b
,
0x1f
,
0x50
,
0x20
,
0x00
,
0x21
,
0x00
,
0x22
,
0x00
,
0x23
,
0x00
,
0x24
,
0xff
,
...
...
@@ -110,16 +119,37 @@ u8 init_tab [] = {
0x33
,
0xfc
,
// rs control
0x34
,
0x93
,
// error control
0x0b
,
0x00
,
0x27
,
0x00
,
0x2f
,
0x00
,
0x30
,
0x00
,
0x35
,
0x00
,
0x36
,
0x00
,
0x37
,
0x00
,
0x38
,
0x00
,
0x39
,
0x00
,
0x3a
,
0x00
,
0x3b
,
0x00
,
0x3c
,
0x00
,
0x3d
,
0x00
,
0x3e
,
0x00
,
0x3f
,
0x00
,
0x40
,
0x00
,
0x41
,
0x00
,
0x42
,
0x00
,
0x43
,
0x00
,
0x44
,
0x00
,
0x45
,
0x00
,
0x46
,
0x00
,
0x47
,
0x00
,
0x48
,
0x00
,
0x49
,
0x00
,
0x4a
,
0x00
,
0x4b
,
0x00
,
0x4c
,
0x00
,
0x4d
,
0x00
,
0x4e
,
0x00
,
0x4f
,
0x00
0x27
,
0x00
,
0x2f
,
0x00
,
0x30
,
0x00
,
0x35
,
0x00
,
0x36
,
0x00
,
0x37
,
0x00
,
0x38
,
0x00
,
0x39
,
0x00
,
0x3a
,
0x00
,
0x3b
,
0x00
,
0x3c
,
0x00
,
0x3d
,
0x00
,
0x3e
,
0x00
,
0x3f
,
0x00
,
0x40
,
0x00
,
0x41
,
0x00
,
0x42
,
0x00
,
0x43
,
0x00
,
0x44
,
0x00
,
0x45
,
0x00
,
0x46
,
0x00
,
0x47
,
0x00
,
0x48
,
0x00
,
0x49
,
0x00
,
0x4a
,
0x00
,
0x4b
,
0x00
,
0x4c
,
0x00
,
0x4d
,
0x00
,
0x4e
,
0x00
,
0x4f
,
0x00
};
...
...
@@ -231,12 +261,27 @@ int stv0299_init (struct dvb_i2c_bus *i2c)
static
int
stv0299_set_inversion
(
struct
dvb_i2c_bus
*
i2c
,
int
inversion
)
int
stv0299_set_inversion
(
struct
dvb_i2c_bus
*
i2c
,
fe_spectral_inversion_t
inversion
)
{
u8
val
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
#ifdef CONFIG_ALPS_BSRU6_IS_LG_TDQBS00X
/* reversed I/Q pins */
switch
(
inversion
)
{
case
INVERSION_AUTO
:
return
-
EOPNOTSUPP
;
case
INVERSION_OFF
:
val
=
stv0299_readreg
(
i2c
,
0x0c
);
return
stv0299_writereg
(
i2c
,
0x0c
,
val
&
0xfe
);
case
INVERSION_ON
:
val
=
stv0299_readreg
(
i2c
,
0x0c
);
return
stv0299_writereg
(
i2c
,
0x0c
,
val
|
0x01
);
default:
return
-
EINVAL
;
};
#else
switch
(
inversion
)
{
case
INVERSION_AUTO
:
return
-
EOPNOTSUPP
;
...
...
@@ -248,7 +293,8 @@ int stv0299_set_inversion (struct dvb_i2c_bus *i2c, int inversion)
return
stv0299_writereg
(
i2c
,
0x0c
,
val
&
0xfe
);
default:
return
-
EINVAL
;
}
};
#endif
}
...
...
@@ -277,9 +323,10 @@ int stv0299_set_FEC (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
static
fe_code_rate_t
stv0299_get_
FEC
(
struct
dvb_i2c_bus
*
i2c
)
fe_code_rate_t
stv0299_get_
fec
(
struct
dvb_i2c_bus
*
i2c
)
{
static
fe_code_rate_t
fec_tab
[]
=
{
FEC_2_3
,
FEC_3_4
,
FEC_5_6
,
FEC_7_8
,
FEC_1_2
};
static
fe_code_rate_t
fec_tab
[]
=
{
FEC_2_3
,
FEC_3_4
,
FEC_5_6
,
FEC_7_8
,
FEC_1_2
};
u8
index
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
...
...
@@ -343,6 +390,9 @@ int stv0299_send_diseqc_msg (struct dvb_i2c_bus *i2c,
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
stv0299_wait_diseqc_idle
(
i2c
,
100
)
<
0
)
return
-
ETIMEDOUT
;
val
=
stv0299_readreg
(
i2c
,
0x08
);
if
(
stv0299_writereg
(
i2c
,
0x08
,
(
val
&
~
0x7
)
|
0x6
))
/* DiSEqC mode */
...
...
@@ -356,12 +406,7 @@ int stv0299_send_diseqc_msg (struct dvb_i2c_bus *i2c,
return
-
EREMOTEIO
;
}
/* Shouldn't we wait for idle state (FE=1, FF=0) here to
make certain all bytes have been sent ?
Hmm, actually we should do that before all mode changes too ...
if (stv0299_wait_diseqc_idle (i2c, 100) < 0) */
if
(
stv0299_wait_diseqc_fifo
(
i2c
,
100
)
<
0
)
if
(
stv0299_wait_diseqc_idle
(
i2c
,
100
)
<
0
)
return
-
ETIMEDOUT
;
return
0
;
...
...
@@ -375,18 +420,18 @@ int stv0299_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t burst)
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
val
=
stv0299_readreg
(
i2c
,
0x08
);
if
(
stv0299_wait_diseqc_fifo
(
i2c
,
100
)
<
0
)
if
(
stv0299_wait_diseqc_idle
(
i2c
,
100
)
<
0
)
return
-
ETIMEDOUT
;
val
=
stv0299_readreg
(
i2c
,
0x08
);
if
(
stv0299_writereg
(
i2c
,
0x08
,
(
val
&
~
0x7
)
|
0x2
))
/* burst mode */
return
-
EREMOTEIO
;
if
(
stv0299_writereg
(
i2c
,
0x09
,
burst
==
SEC_MINI_A
?
0x00
:
0xff
))
return
-
EREMOTEIO
;
if
(
stv0299_wait_diseqc_
fifo
(
i2c
,
100
)
<
0
)
if
(
stv0299_wait_diseqc_
idle
(
i2c
,
100
)
<
0
)
return
-
ETIMEDOUT
;
if
(
stv0299_writereg
(
i2c
,
0x08
,
val
))
...
...
@@ -403,6 +448,9 @@ int stv0299_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone)
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
stv0299_wait_diseqc_idle
(
i2c
,
100
)
<
0
)
return
-
ETIMEDOUT
;
val
=
stv0299_readreg
(
i2c
,
0x08
);
switch
(
tone
)
{
...
...
@@ -445,8 +493,6 @@ int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
u32
tmp
;
u8
aclk
=
0xb4
,
bclk
=
0x51
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
srate
>
M_CLK
)
srate
=
M_CLK
;
if
(
srate
<
500000
)
...
...
@@ -479,7 +525,6 @@ int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
}
static
int
stv0299_get_symbolrate
(
struct
dvb_i2c_bus
*
i2c
)
{
...
...
@@ -608,7 +653,7 @@ int bsru6_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
p
->
frequency
+=
derot_freq
;
p
->
inversion
=
(
stv0299_readreg
(
i2c
,
0x0c
)
&
1
)
?
INVERSION_OFF
:
INVERSION_ON
;
p
->
u
.
qpsk
.
fec_inner
=
stv0299_get_
FEC
(
i2c
);
p
->
u
.
qpsk
.
fec_inner
=
stv0299_get_
fec
(
i2c
);
p
->
u
.
qpsk
.
symbol_rate
=
stv0299_get_symbolrate
(
i2c
);
break
;
}
...
...
@@ -694,7 +739,7 @@ module_exit (exit_bsru6);
MODULE_PARM
(
debug
,
"i"
);
MODULE_PARM_DESC
(
debug
,
"enable verbose debug messages"
);
MODULE_DESCRIPTION
(
"
BSRU6
DVB Frontend driver"
);
MODULE_DESCRIPTION
(
"
Alps BSRU6/LG TDQB-S00x
DVB Frontend driver"
);
MODULE_AUTHOR
(
"Ralph Metzler, Holger Waechtler"
);
MODULE_LICENSE
(
"GPL"
);
drivers/media/dvb/frontends/alps_bsrv2.c
View file @
888c9d64
...
...
@@ -342,7 +342,7 @@ int bsrv2_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
*
ber
=
ves1893_readreg
(
i2c
,
0x15
);
*
ber
|=
(
ves1893_readreg
(
i2c
,
0x16
)
<<
8
);
*
ber
|=
(
ves1893_readreg
(
i2c
,
0x17
)
<<
16
);
*
ber
|=
(
(
ves1893_readreg
(
i2c
,
0x17
)
&
0x0f
)
<<
16
);
*
ber
*=
10
;
break
;
}
...
...
drivers/media/dvb/frontends/alps_tdlb7.c
0 → 100644
View file @
888c9d64
/*
Driver for Alps TDLB7 Frontend
Copyright (C) 1999 Juergen Peitz <peitz@snafu.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
Wrote this code mainly to get my own card running. It's working for me, but I
hope somebody who knows more about linux programming and the DVB driver can
improve it.
Reused a lot from the existing driver and tuner code.
Thanks to everybody who worked on it!
This driver needs a copy of the microcode file 'Sc_main.mc' from the Haupauge
windows driver in the 'usr/lib/DVB/driver/frontends' directory.
You can also pass the complete file name with the module parameter 'mcfile'.
The code only needs to be loaded once after a power on. Because loading the
microcode to the card takes some time, you can use the 'loadcode=0' module
parameter, if you only want to reload the dvb driver.
Juergen Peitz
*/
#define __KERNEL_SYSCALLS__
#include <linux/module.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/unistd.h>
#include "compat.h"
#include "dvb_frontend.h"
static
int
debug
=
0
;
static
int
loadcode
=
1
;
static
char
*
mcfile
=
"/usr/lib/DVB/driver/frontends/Sc_main.mc"
;
#define dprintk if (debug) printk
/* microcode size for sp8870 */
#define SP8870_CODE_SIZE 16384
/* starting point for microcode in file 'Sc_main.mc' */
#define SP8870_CODE_OFFSET 0x0A
static
int
errno
;
static
struct
dvb_frontend_info
tdlb7_info
=
{
name:
"Alps TDLB7"
,
type:
FE_OFDM
,
frequency_min:
470000000
,
frequency_max:
860000000
,
frequency_stepsize:
166666
,
#if 0
frequency_tolerance: ???,
symbol_rate_min: ???,
symbol_rate_max: ???,
symbol_rate_tolerance: ???,
notifier_delay: 0,
#endif
caps:
FE_CAN_FEC_1_2
|
FE_CAN_FEC_2_3
|
FE_CAN_FEC_3_4
|
FE_CAN_FEC_5_6
|
FE_CAN_FEC_7_8
|
FE_CAN_FEC_AUTO
|
FE_CAN_QPSK
|
FE_CAN_QAM_16
|
FE_CAN_QAM_64
};
static
int
sp8870_writereg
(
struct
dvb_i2c_bus
*
i2c
,
u16
reg
,
u16
data
)
{
u8
buf
[]
=
{
reg
>>
8
,
reg
&
0xff
,
data
>>
8
,
data
&
0xff
};
struct
i2c_msg
msg
=
{
addr
:
0x71
,
flags
:
0
,
buf
:
buf
,
len
:
4
};
int
err
;
if
((
err
=
i2c
->
xfer
(
i2c
,
&
msg
,
1
))
!=
1
)
{
dprintk
(
"%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)
\n
"
,
__FUNCTION__
,
err
,
reg
,
data
);
return
-
EREMOTEIO
;
}
return
0
;
}
static
u16
sp8870_readreg
(
struct
dvb_i2c_bus
*
i2c
,
u16
reg
)
{
int
ret
;
u8
b0
[]
=
{
reg
>>
8
,
reg
&
0xff
};
u8
b1
[]
=
{
0
,
0
};
struct
i2c_msg
msg
[]
=
{
{
addr
:
0x71
,
flags
:
0
,
buf
:
b0
,
len
:
2
},
{
addr
:
0x71
,
flags
:
I2C_M_RD
,
buf
:
b1
,
len
:
2
}
};
ret
=
i2c
->
xfer
(
i2c
,
msg
,
2
);
if
(
ret
!=
2
)
dprintk
(
"%s: readreg error (ret == %i)
\n
"
,
__FUNCTION__
,
ret
);
return
(
b1
[
0
]
<<
8
|
b1
[
1
]);
}
static
int
sp5659_write
(
struct
dvb_i2c_bus
*
i2c
,
u8
data
[
4
])
{
int
ret
;
struct
i2c_msg
msg
=
{
addr
:
0x60
,
flags
:
0
,
buf
:
data
,
len
:
4
};
ret
=
i2c
->
xfer
(
i2c
,
&
msg
,
1
);
if
(
ret
!=
1
)
printk
(
"%s: i/o error (ret == %i)
\n
"
,
__FUNCTION__
,
ret
);
return
(
ret
!=
1
)
?
-
1
:
0
;
}
static
int
sp5659_set_tv_freq
(
struct
dvb_i2c_bus
*
i2c
,
u32
freq
,
u8
pwr
)
{
u32
div
=
(
freq
+
36200000
)
/
166666
;
u8
buf
[
4
]
=
{
(
div
>>
8
)
&
0x7f
,
div
&
0xff
,
0x85
,
(
pwr
<<
5
)
|
0x30
};
return
sp5659_write
(
i2c
,
buf
);
}
static
int
sp8870_read_code
(
const
char
*
fn
,
char
**
fp
)
{
int
fd
;
loff_t
l
;
char
*
dp
;
fd
=
open
(
fn
,
0
,
0
);
if
(
fd
==
-
1
)
{
printk
(
KERN_INFO
"%s: Unable to load '%s'.
\n
"
,
__FUNCTION__
,
fn
);
return
-
1
;
}
l
=
lseek
(
fd
,
0L
,
2
);
if
(
l
<=
0
||
l
<
SP8870_CODE_OFFSET
+
SP8870_CODE_SIZE
)
{
printk
(
KERN_INFO
"%s: code file too small '%s'
\n
"
,
__FUNCTION__
,
fn
);
sys_close
(
fd
);
return
-
1
;
}
lseek
(
fd
,
SP8870_CODE_OFFSET
,
0
);
*
fp
=
dp
=
vmalloc
(
SP8870_CODE_SIZE
);
if
(
dp
==
NULL
)
{
printk
(
KERN_INFO
"%s: Out of memory loading '%s'.
\n
"
,
__FUNCTION__
,
fn
);
sys_close
(
fd
);
return
-
1
;
}
if
(
read
(
fd
,
dp
,
SP8870_CODE_SIZE
)
!=
SP8870_CODE_SIZE
)
{
printk
(
KERN_INFO
"%s: Failed to read '%s'.
\n
"
,
__FUNCTION__
,
fn
);
vfree
(
dp
);
sys_close
(
fd
);
return
-
1
;
}
sys_close
(
fd
);
*
fp
=
dp
;
return
0
;
}
static
int
sp8870_load_code
(
struct
dvb_i2c_bus
*
i2c
)
{
/* this takes a long time. is there a way to do it faster? */
char
*
lcode
;
struct
i2c_msg
msg
;
unsigned
char
buf
[
255
];
int
err
;
int
p
=
0
;
int
c
;
mm_segment_t
fs
=
get_fs
();
sp8870_writereg
(
i2c
,
0x8F08
,
0x1FFF
);
sp8870_writereg
(
i2c
,
0x8F0A
,
0x0000
);
set_fs
(
get_ds
());
if
(
sp8870_read_code
(
mcfile
,(
char
**
)
&
lcode
)
<
0
)
return
-
1
;
set_fs
(
fs
);
while
(
p
<
SP8870_CODE_SIZE
){
c
=
(
p
<=
SP8870_CODE_SIZE
-
252
)
?
252
:
SP8870_CODE_SIZE
-
p
;
buf
[
0
]
=
0xCF
;
buf
[
1
]
=
0x0A
;
memcpy
(
&
buf
[
2
],
lcode
+
p
,
c
);
c
+=
2
;
msg
.
addr
=
0x71
;
msg
.
flags
=
0
;
msg
.
buf
=
buf
;
msg
.
len
=
c
;
if
((
err
=
i2c
->
xfer
(
i2c
,
&
msg
,
1
))
!=
1
)
{
dprintk
(
"%s: i2c error (err == %i)
\n
"
,
__FUNCTION__
,
err
);
vfree
(
lcode
);
return
-
EREMOTEIO
;
}
p
+=
252
;
}
vfree
(
lcode
);
return
0
;
};
static
int
sp8870_init
(
struct
dvb_i2c_bus
*
i2c
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
sp8870_readreg
(
i2c
,
0x200
);
sp8870_readreg
(
i2c
,
0x200
);
sp8870_readreg
(
i2c
,
0x0F00
);
/* system controller stop */
sp8870_readreg
(
i2c
,
0x0301
);
/* ???????? */
sp8870_readreg
(
i2c
,
0x0309
);
/* integer carrier offset */
sp8870_readreg
(
i2c
,
0x030A
);
/* fractional carrier offset */
sp8870_readreg
(
i2c
,
0x0311
);
/* filter for 8 Mhz channel */
sp8870_readreg
(
i2c
,
0x0319
);
/* sample rate correction bit [23..17] */
sp8870_readreg
(
i2c
,
0x031A
);
/* sample rate correction bit [16..0] */
sp8870_readreg
(
i2c
,
0x0338
);
/* ???????? */
sp8870_readreg
(
i2c
,
0x0F00
);
sp8870_readreg
(
i2c
,
0x0200
);
if
(
loadcode
)
{
dprintk
(
"%s: loading mcfile '%s' !
\n
"
,
__FUNCTION__
,
mcfile
);
if
(
sp8870_load_code
(
i2c
)
==
0
)
dprintk
(
"%s: microcode loaded!
\n
"
,
__FUNCTION__
);
}
else
{
dprintk
(
"%s: without loading mcfile!
\n
"
,
__FUNCTION__
);
}
return
0
;
}
static
int
sp8870_reset
(
struct
dvb_i2c_bus
*
i2c
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
sp8870_writereg
(
i2c
,
0x0F00
,
0x0000
);
/* system controller stop */
sp8870_writereg
(
i2c
,
0x0301
,
0x0003
);
/* ???????? */
sp8870_writereg
(
i2c
,
0x0309
,
0x0400
);
/* integer carrier offset */
sp8870_writereg
(
i2c
,
0x030A
,
0x0000
);
/* fractional carrier offset */
sp8870_writereg
(
i2c
,
0x0311
,
0x0000
);
/* filter for 8 Mhz channel */
sp8870_writereg
(
i2c
,
0x0319
,
0x000A
);
/* sample rate correction bit [23..17] */
sp8870_writereg
(
i2c
,
0x031A
,
0x0AAB
);
/* sample rate correction bit [16..0] */
sp8870_writereg
(
i2c
,
0x0338
,
0x0000
);
/* ???????? */
sp8870_writereg
(
i2c
,
0x0201
,
0x0000
);
/* interrupts for change of lock or tuner adjustment disabled */
sp8870_writereg
(
i2c
,
0x0F00
,
0x0001
);
/* system controller start */
return
0
;
}
static
int
tdlb7_ioctl
(
struct
dvb_frontend
*
fe
,
unsigned
int
cmd
,
void
*
arg
)
{
struct
dvb_i2c_bus
*
i2c
=
fe
->
i2c
;
switch
(
cmd
)
{
case
FE_GET_INFO
:
memcpy
(
arg
,
&
tdlb7_info
,
sizeof
(
struct
dvb_frontend_info
));
break
;
case
FE_READ_STATUS
:
{
fe_status_t
*
status
=
arg
;
int
sync
=
sp8870_readreg
(
i2c
,
0x0200
);
*
status
=
0
;
if
(
sync
&
0x04
)
// FIXME: find criteria for having signal
*
status
|=
FE_HAS_SIGNAL
;
if
(
sync
&
0x04
)
// FIXME: find criteria
*
status
|=
FE_HAS_CARRIER
;
if
(
sync
&
0x04
)
// FIXME
*
status
|=
FE_HAS_VITERBI
;
if
(
sync
&
0x08
)
// FIXME
*
status
|=
FE_HAS_SYNC
;
if
(
sync
&
0x04
)
*
status
|=
FE_HAS_LOCK
;
break
;
}
case
FE_READ_BER
:
{
u32
*
ber
=
(
u32
*
)
arg
;
*
ber
=
sp8870_readreg
(
i2c
,
0x0C07
);
// bit error rate before Viterbi
break
;
}
case
FE_READ_SIGNAL_STRENGTH
:
// not supported by hardware?
{
s32
*
signal
=
(
s32
*
)
arg
;
*
signal
=
0
;
break
;
}
case
FE_READ_SNR
:
// not supported by hardware?
{
s32
*
snr
=
(
s32
*
)
arg
;
*
snr
=
0
;
break
;
}
case
FE_READ_UNCORRECTED_BLOCKS
:
// not supported by hardware?
{
u32
*
ublocks
=
(
u32
*
)
arg
;
*
ublocks
=
0
;
break
;
}
case
FE_SET_FRONTEND
:
{
struct
dvb_frontend_parameters
*
p
=
arg
;
sp5659_set_tv_freq
(
i2c
,
p
->
frequency
,
0
);
// all other parameters are set by the on card
// system controller. Don't know how to pass
// distinct values to the card.
break
;
}
case
FE_GET_FRONTEND
:
// how to do this?
{
break
;
}
case
FE_SLEEP
:
// is this supported by hardware?
return
-
EOPNOTSUPP
;
case
FE_INIT
:
return
sp8870_init
(
i2c
);
case
FE_RESET
:
return
sp8870_reset
(
i2c
);
default:
return
-
EOPNOTSUPP
;
};
return
0
;
}
static
int
tdlb7_attach
(
struct
dvb_i2c_bus
*
i2c
)
{
struct
i2c_msg
msg
=
{
addr
:
0x71
,
flags
:
0
,
buf
:
NULL
,
len
:
0
};
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
i2c
->
xfer
(
i2c
,
&
msg
,
1
)
!=
1
)
return
-
ENODEV
;
dvb_register_frontend
(
tdlb7_ioctl
,
i2c
,
NULL
,
&
tdlb7_info
);
return
0
;
}
static
void
tdlb7_detach
(
struct
dvb_i2c_bus
*
i2c
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
dvb_unregister_frontend
(
tdlb7_ioctl
,
i2c
);
}
static
int
__init
init_tdlb7
(
void
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
return
dvb_register_i2c_device
(
THIS_MODULE
,
tdlb7_attach
,
tdlb7_detach
);
}
static
void
__exit
exit_tdlb7
(
void
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
dvb_unregister_i2c_device
(
tdlb7_attach
);
}
module_init
(
init_tdlb7
);
module_exit
(
exit_tdlb7
);
MODULE_PARM
(
debug
,
"i"
);
MODULE_PARM_DESC
(
debug
,
"enable verbose debug messages"
);
MODULE_PARM
(
loadcode
,
"i"
);
MODULE_PARM_DESC
(
loadcode
,
"load tuner microcode"
);
MODULE_PARM
(
mcfile
,
"s"
);
MODULE_PARM_DESC
(
mcfile
,
"where to find the microcode file"
);
MODULE_DESCRIPTION
(
"TDLB7 DVB-T Frontend"
);
MODULE_AUTHOR
(
"Juergen Peitz"
);
MODULE_LICENSE
(
"GPL"
);
drivers/media/dvb/frontends/alps_tdmb7.c
0 → 100644
View file @
888c9d64
/*
Alps TDMB7 DVB OFDM frontend driver
Copyright (C) 2001-2002 Convergence Integrated Media GmbH
Holger Waechtler <holger@convergence.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/init.h>
#include <linux/module.h>
#include "compat.h"
#include "dvb_frontend.h"
static
int
debug
=
0
;
#define dprintk if (debug) printk
static
struct
dvb_frontend_info
tdmb7_info
=
{
name:
"Alps TDMB7"
,
type:
FE_OFDM
,
frequency_min:
470000000
,
frequency_max:
860000000
,
frequency_stepsize:
166667
,
#if 0
frequency_tolerance: ???,
symbol_rate_min: ???,
symbol_rate_max: ???,
symbol_rate_tolerance: 500, /* ppm */
notifier_delay: 0,
#endif
caps:
FE_CAN_FEC_1_2
|
FE_CAN_FEC_2_3
|
FE_CAN_FEC_3_4
|
FE_CAN_FEC_5_6
|
FE_CAN_FEC_7_8
|
FE_CAN_FEC_AUTO
|
FE_CAN_QPSK
|
FE_CAN_QAM_16
|
FE_CAN_QAM_64
};
static
inline
void
ddelay
(
int
timeout
)
{
current
->
state
=
TASK_INTERRUPTIBLE
;
schedule_timeout
(
timeout
);
}
static
u8
init_tab
[]
=
{
0x04
,
0x10
,
0x05
,
0x09
,
0x06
,
0x00
,
0x08
,
0x04
,
0x09
,
0x00
,
0x0a
,
0x01
,
0x15
,
0x40
,
0x16
,
0x10
,
0x17
,
0x87
,
0x18
,
0x17
,
0x1a
,
0x10
,
0x25
,
0x04
,
0x2e
,
0x00
,
0x39
,
0x00
,
0x3a
,
0x04
,
0x45
,
0x08
,
0x46
,
0x02
,
0x47
,
0x05
,
};
static
int
cx22700_writereg
(
struct
dvb_i2c_bus
*
i2c
,
u8
reg
,
u8
data
)
{
int
ret
;
u8
buf
[]
=
{
reg
,
data
};
struct
i2c_msg
msg
=
{
addr
:
0x43
,
flags
:
0
,
buf
:
buf
,
len
:
2
};
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
ret
=
i2c
->
xfer
(
i2c
,
&
msg
,
1
);
if
(
ret
!=
1
)
printk
(
"%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)
\n
"
,
__FUNCTION__
,
reg
,
data
,
ret
);
return
(
ret
!=
1
)
?
-
1
:
0
;
}
static
u8
cx22700_readreg
(
struct
dvb_i2c_bus
*
i2c
,
u8
reg
)
{
int
ret
;
u8
b0
[]
=
{
reg
};
u8
b1
[]
=
{
0
};
struct
i2c_msg
msg
[]
=
{
{
addr
:
0x43
,
flags
:
0
,
buf
:
b0
,
len
:
1
},
{
addr
:
0x43
,
flags
:
I2C_M_RD
,
buf
:
b1
,
len
:
1
}
};
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
ret
=
i2c
->
xfer
(
i2c
,
msg
,
2
);
if
(
ret
!=
2
)
printk
(
"%s: readreg error (ret == %i)
\n
"
,
__FUNCTION__
,
ret
);
return
b1
[
0
];
}
static
int
pll_write
(
struct
dvb_i2c_bus
*
i2c
,
u8
data
[
4
])
{
struct
i2c_msg
msg
=
{
addr
:
0x61
,
flags
:
0
,
buf
:
data
,
len
:
4
};
int
ret
;
cx22700_writereg
(
i2c
,
0x0a
,
0x00
);
/* open i2c bus switch */
ret
=
i2c
->
xfer
(
i2c
,
&
msg
,
1
);
cx22700_writereg
(
i2c
,
0x0a
,
0x01
);
/* close i2c bus switch */
if
(
ret
!=
1
)
printk
(
"%s: i/o error (addr == 0x%02x, ret == %i)
\n
"
,
__FUNCTION__
,
msg
.
addr
,
ret
);
return
(
ret
!=
1
)
?
-
1
:
0
;
}
/**
* set up the downconverter frequency divisor for a
* reference clock comparision frequency of 125 kHz.
*/
static
int
pll_set_tv_freq
(
struct
dvb_i2c_bus
*
i2c
,
u32
freq
)
{
u32
div
=
(
freq
+
36166667
)
/
166667
;
#if 1 //ALPS_SETTINGS
u8
buf
[
4
]
=
{
(
div
>>
8
)
&
0x7f
,
div
&
0xff
,
((
div
>>
10
)
&
0x60
)
|
0x85
,
freq
<
592000000
?
0x40
:
0x80
};
#else
u8
buf
[
4
]
=
{
(
div
>>
8
)
&
0x7f
,
div
&
0xff
,
((
div
>>
10
)
&
0x60
)
|
0x85
,
freq
<
470000000
?
0x42
:
freq
<
862000000
?
0x41
:
0x81
};
#endif
dprintk
(
"%s: freq == %i, div == %i
\n
"
,
__FUNCTION__
,
freq
,
div
);
return
pll_write
(
i2c
,
buf
);
}
static
int
cx22700_init
(
struct
dvb_i2c_bus
*
i2c
)
{
int
i
;
dprintk
(
"cx22700_init: init chip
\n
"
);
cx22700_writereg
(
i2c
,
0x00
,
0x02
);
/* soft reset */
cx22700_writereg
(
i2c
,
0x00
,
0x00
);
ddelay
(
HZ
/
100
);
for
(
i
=
0
;
i
<
sizeof
(
init_tab
);
i
+=
2
)
cx22700_writereg
(
i2c
,
init_tab
[
i
],
init_tab
[
i
+
1
]);
cx22700_writereg
(
i2c
,
0x00
,
0x01
);
return
0
;
}
static
int
cx22700_set_inversion
(
struct
dvb_i2c_bus
*
i2c
,
int
inversion
)
{
u8
val
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
switch
(
inversion
)
{
case
INVERSION_AUTO
:
return
-
EOPNOTSUPP
;
case
INVERSION_ON
:
val
=
cx22700_readreg
(
i2c
,
0x09
);
return
cx22700_writereg
(
i2c
,
0x09
,
val
|
0x01
);
case
INVERSION_OFF
:
val
=
cx22700_readreg
(
i2c
,
0x09
);
return
cx22700_writereg
(
i2c
,
0x09
,
val
&
0xfe
);
default:
return
-
EINVAL
;
}
}
static
int
cx22700_set_tps
(
struct
dvb_i2c_bus
*
i2c
,
struct
dvb_ofdm_parameters
*
p
)
{
static
const
u8
qam_tab
[
4
]
=
{
0
,
1
,
0
,
2
};
static
const
u8
fec_tab
[
6
]
=
{
0
,
1
,
2
,
0
,
3
,
4
};
u8
val
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
p
->
code_rate_HP
<
FEC_1_2
||
p
->
code_rate_HP
>
FEC_7_8
)
return
-
EINVAL
;
if
(
p
->
code_rate_LP
<
FEC_1_2
||
p
->
code_rate_LP
>
FEC_7_8
)
if
(
p
->
code_rate_HP
==
FEC_4_5
||
p
->
code_rate_LP
==
FEC_4_5
)
return
-
EINVAL
;
if
(
p
->
guard_interval
<
GUARD_INTERVAL_1_32
||
p
->
guard_interval
>
GUARD_INTERVAL_1_4
)
return
-
EINVAL
;
if
(
p
->
transmission_mode
!=
TRANSMISSION_MODE_2K
&&
p
->
transmission_mode
!=
TRANSMISSION_MODE_8K
)
return
-
EINVAL
;
if
(
p
->
constellation
!=
QPSK
&&
p
->
constellation
!=
QAM_16
&&
p
->
constellation
!=
QAM_64
)
return
-
EINVAL
;
if
(
p
->
hierarchy_information
<
HIERARCHY_NONE
||
p
->
hierarchy_information
>
HIERARCHY_4
)
return
-
EINVAL
;
if
(
p
->
bandwidth
<
BANDWIDTH_8_MHZ
&&
p
->
bandwidth
>
BANDWIDTH_6_MHZ
)
return
-
EINVAL
;
if
(
p
->
bandwidth
==
BANDWIDTH_7_MHZ
)
cx22700_writereg
(
i2c
,
0x09
,
cx22700_readreg
(
i2c
,
0x09
|
0x10
));
else
cx22700_writereg
(
i2c
,
0x09
,
cx22700_readreg
(
i2c
,
0x09
&
~
0x10
));
val
=
qam_tab
[
p
->
constellation
-
QPSK
];
val
|=
p
->
hierarchy_information
-
HIERARCHY_NONE
;
cx22700_writereg
(
i2c
,
0x04
,
val
);
val
=
fec_tab
[
p
->
code_rate_HP
-
FEC_1_2
]
<<
3
;
val
|=
fec_tab
[
p
->
code_rate_LP
-
FEC_1_2
];
cx22700_writereg
(
i2c
,
0x05
,
val
);
val
=
(
p
->
guard_interval
-
GUARD_INTERVAL_1_32
)
<<
2
;
val
|=
p
->
transmission_mode
-
TRANSMISSION_MODE_2K
;
cx22700_writereg
(
i2c
,
0x06
,
val
);
cx22700_writereg
(
i2c
,
0x08
,
0x04
|
0x02
);
/* use user tps parameters */
cx22700_writereg
(
i2c
,
0x08
,
0x04
);
/* restart aquisition */
return
0
;
}
static
int
cx22700_get_tps
(
struct
dvb_i2c_bus
*
i2c
,
struct
dvb_ofdm_parameters
*
p
)
{
static
const
fe_modulation_t
qam_tab
[
3
]
=
{
QPSK
,
QAM_16
,
QAM_64
};
static
const
fe_code_rate_t
fec_tab
[
5
]
=
{
FEC_1_2
,
FEC_2_3
,
FEC_3_4
,
FEC_5_6
,
FEC_7_8
};
u8
val
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
!
(
cx22700_readreg
(
i2c
,
0x07
)
&
0x20
))
/* tps valid? */
return
-
EAGAIN
;
val
=
cx22700_readreg
(
i2c
,
0x01
);
if
((
val
&
0x7
)
>
4
)
p
->
hierarchy_information
=
HIERARCHY_AUTO
;
else
p
->
hierarchy_information
=
HIERARCHY_NONE
+
(
val
&
0x7
);
if
(((
val
>>
3
)
&
0x3
)
>
2
)
p
->
constellation
=
QAM_AUTO
;
else
p
->
constellation
=
qam_tab
[(
val
>>
3
)
&
0x3
];
val
=
cx22700_readreg
(
i2c
,
0x02
);
if
((
val
>>
3
)
>
4
)
p
->
code_rate_HP
=
FEC_AUTO
;
else
p
->
code_rate_HP
=
fec_tab
[
val
>>
3
];
if
((
val
&
0x7
)
>
4
)
p
->
code_rate_LP
=
FEC_AUTO
;
else
p
->
code_rate_LP
=
fec_tab
[
val
>>
3
];
val
=
cx22700_readreg
(
i2c
,
0x03
);
p
->
guard_interval
=
GUARD_INTERVAL_1_32
+
((
val
>>
6
)
&
0x3
);
p
->
transmission_mode
=
TRANSMISSION_MODE_2K
+
((
val
>>
5
)
&
0x1
);
return
0
;
}
static
int
tdmb7_ioctl
(
struct
dvb_frontend
*
fe
,
unsigned
int
cmd
,
void
*
arg
)
{
struct
dvb_i2c_bus
*
i2c
=
fe
->
i2c
;
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
switch
(
cmd
)
{
case
FE_GET_INFO
:
memcpy
(
arg
,
&
tdmb7_info
,
sizeof
(
struct
dvb_frontend_info
));
break
;
case
FE_READ_STATUS
:
{
fe_status_t
*
status
=
(
fe_status_t
*
)
arg
;
u16
rs_ber
=
(
cx22700_readreg
(
i2c
,
0x0d
)
<<
9
)
|
(
cx22700_readreg
(
i2c
,
0x0e
)
<<
1
);
u8
sync
=
cx22700_readreg
(
i2c
,
0x07
);
*
status
=
0
;
if
(
rs_ber
<
0xff00
)
*
status
|=
FE_HAS_SIGNAL
;
if
(
sync
&
0x20
)
*
status
|=
FE_HAS_CARRIER
;
if
(
sync
&
0x10
)
*
status
|=
FE_HAS_VITERBI
;
if
(
sync
&
0x10
)
*
status
|=
FE_HAS_SYNC
;
if
(
sync
&
0x10
)
*
status
|=
FE_HAS_LOCK
;
break
;
}
case
FE_READ_BER
:
*
((
uint32_t
*
)
arg
)
=
cx22700_readreg
(
i2c
,
0x0c
)
&
0x7f
;
break
;
case
FE_READ_SIGNAL_STRENGTH
:
{
u16
rs_ber
=
(
cx22700_readreg
(
i2c
,
0x0d
)
<<
9
)
|
(
cx22700_readreg
(
i2c
,
0x0e
)
<<
1
);
*
((
uint16_t
*
)
arg
)
=
~
rs_ber
;
break
;
}
case
FE_READ_SNR
:
{
u16
rs_ber
=
(
cx22700_readreg
(
i2c
,
0x0d
)
<<
9
)
|
(
cx22700_readreg
(
i2c
,
0x0e
)
<<
1
);
*
((
uint16_t
*
)
arg
)
=
~
rs_ber
;
break
;
}
case
FE_READ_UNCORRECTED_BLOCKS
:
*
((
uint32_t
*
)
arg
)
=
cx22700_readreg
(
i2c
,
0x0f
);
break
;
case
FE_SET_FRONTEND
:
{
struct
dvb_frontend_parameters
*
p
=
arg
;
cx22700_writereg
(
i2c
,
0x00
,
0x02
);
/* XXX CHECKME: soft reset*/
cx22700_writereg
(
i2c
,
0x00
,
0x00
);
pll_set_tv_freq
(
i2c
,
p
->
frequency
);
cx22700_set_inversion
(
i2c
,
p
->
inversion
);
cx22700_set_tps
(
i2c
,
&
p
->
u
.
ofdm
);
cx22700_writereg
(
i2c
,
0x37
,
0x01
);
/* PAL loop filter off */
cx22700_writereg
(
i2c
,
0x00
,
0x01
);
/* restart aquire */
break
;
}
case
FE_GET_FRONTEND
:
{
struct
dvb_frontend_parameters
*
p
=
arg
;
u8
reg09
=
cx22700_readreg
(
i2c
,
0x09
);
p
->
inversion
=
reg09
&
0x1
?
INVERSION_ON
:
INVERSION_OFF
;
return
cx22700_get_tps
(
i2c
,
&
p
->
u
.
ofdm
);
}
case
FE_INIT
:
return
cx22700_init
(
i2c
);
case
FE_RESET
:
break
;
default:
return
-
EOPNOTSUPP
;
};
return
0
;
}
static
int
tdmb7_attach
(
struct
dvb_i2c_bus
*
i2c
)
{
struct
i2c_msg
msg
=
{
addr
:
0x43
,
flags
:
0
,
buf
:
NULL
,
len
:
0
};
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
if
(
i2c
->
xfer
(
i2c
,
&
msg
,
1
)
!=
1
)
return
-
ENODEV
;
dvb_register_frontend
(
tdmb7_ioctl
,
i2c
,
NULL
,
&
tdmb7_info
);
return
0
;
}
static
void
tdmb7_detach
(
struct
dvb_i2c_bus
*
i2c
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
dvb_unregister_frontend
(
tdmb7_ioctl
,
i2c
);
}
static
int
__init
init_tdmb7
(
void
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
return
dvb_register_i2c_device
(
THIS_MODULE
,
tdmb7_attach
,
tdmb7_detach
);
}
static
void
__exit
exit_tdmb7
(
void
)
{
dprintk
(
"%s
\n
"
,
__FUNCTION__
);
dvb_unregister_i2c_device
(
tdmb7_attach
);
}
module_init
(
init_tdmb7
);
module_exit
(
exit_tdmb7
);
MODULE_PARM
(
debug
,
"i"
);
MODULE_PARM_DESC
(
debug
,
"enable verbose debug messages"
);
MODULE_DESCRIPTION
(
"TDMB7 DVB Frontend driver"
);
MODULE_AUTHOR
(
"Holger Waechtler"
);
MODULE_LICENSE
(
"GPL"
);
drivers/media/dvb/frontends/ves1820.c
View file @
888c9d64
...
...
@@ -199,8 +199,8 @@ int ves1820_init (struct dvb_frontend *frontend)
u8
b0
[]
=
{
0xff
};
u8
pwm
;
int
i
;
struct
i2c_msg
msg
[]
=
{
{
addr
:
0x
28
,
flags
:
0
,
buf
:
b0
,
len
:
1
},
{
addr
:
0x
28
,
flags
:
I2C_M_RD
,
buf
:
&
pwm
,
len
:
1
}
};
struct
i2c_msg
msg
[]
=
{
{
addr
:
0x
50
,
flags
:
0
,
buf
:
b0
,
len
:
1
},
{
addr
:
0x
50
,
flags
:
I2C_M_RD
,
buf
:
&
pwm
,
len
:
1
}
};
dprintk
(
"VES1820: init chip
\n
"
);
...
...
@@ -433,12 +433,13 @@ int ves1820_ioctl (struct dvb_frontend *frontend, unsigned int cmd, void *arg)
}
case
FE_READ_BER
:
*
((
u32
*
)
arg
)
=
ves1820_readreg
(
frontend
->
i2c
,
0x14
)
|
{
u32
ber
=
ves1820_readreg
(
frontend
->
i2c
,
0x14
)
|
(
ves1820_readreg
(
frontend
->
i2c
,
0x15
)
<<
8
)
|
(
ves1820_readreg
(
frontend
->
i2c
,
0x16
)
<<
16
);
/* XXX FIXME: scale!!*/
((
ves1820_readreg
(
frontend
->
i2c
,
0x16
)
&
0x0f
)
<<
16
);
*
((
u32
*
)
arg
)
=
10
*
ber
;
break
;
}
case
FE_READ_SIGNAL_STRENGTH
:
{
u8
gain
=
ves1820_readreg
(
frontend
->
i2c
,
0x17
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment