Audio mode changes are not private to the audio chip - other I2C
modules need to see this as well. And since the command in question
is VIDIOC_S_TUNER which is a standard v4l2 command, we really should
be broadcasting it out. This change sets up a broadcast pathway for
VIDIOC_S_TUNER and also eliminates the now redundant code from the
audio chip handler.
This fix enables stereo reception for the FM radio
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Attempts to enumerate or operate on a group of EXT_CTRLS where the
group size is zero is OK; don't fail on such operations. At least one
application uses this to probe for the existence of this API so let it
succeed.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This bug caused uninitalized data to be returned during a G_TUNER status poll.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The lack of a break statement in the handling of VIDIOC_S_TUNER caused
errors to result. Fixed.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Rather than hardcoding frequency ranges everywhere, rely on
VIDIOC_G_TUNER results wherever we can.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The automodeswitch control was a feature that enable automatic radio /
tv switching based on the selected frequency. However since frequency
ranges can overlap and also since apparently in some cases it's
possible for the same frequency range to be both tv and radio in a
specific region, then this feature can't safely work. So it's removed.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Clean up use of VIDIOC_G_TUNER; we now correctly gather info from all
the I2C client modules. Also abide by V4L2_TUNER_CAP_LOW
appropriately.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.
Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
If assigned minor is 10 or greater, terminator will be put beyound the end.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Switch back to the previous input selection when the radio device is
closed - but only do that if the current input selection is still the
radio (i.e. it appears that it hasn't been messed with).
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
When the input is switched by opening /dev/radioX, we must also commit
that change into the driver core.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Clean up and tighten logic involving stream configuration. This
mainly involves changes to pvrusb2-v4l2.c, where we better clarify how
we use the stream configuration enum and implement a cleaner means to
control streaming for a given device node.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The default volume of 65535 is too high. Make is something smaller.
Note that this _only_ changes the default value. Specifically, there
are no scaling or other more intrusive changes here. I'm just sick of
constantly having to reduce the volume every time I plug in and test
the device! (And unfortunately we can't do a better fix like scaling
the volume so that 65535 makes sense because doing so will screw up
any app - like MythTV - which expects the old scaling.) Too bad V4L
controls don't have better defined ranges.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Trying to temporarily check that the stream is not claimed during open
of the radio device is at best a race condition. What's to stop
another app from claiming the stream anyway the instant after the
check is done? The implementation for this was dicey anyway. So it's
removed. The only "price" for this is that if /dev/radioX is opened
while streaming video, then the video stream is just going to switch
to radio mode anyway. If a user does this, he gets what he expects...
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Separate track radio versus tv frequency so that when we switch modes
we can also switch to a sane frequency appropriate for the mode. Also
implement logic to automate mode switching in certain cases.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Implement new method for doing integer range checking, so that we can
more intelligently range-check radio and tv ranges at once.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
These changes implement correct audio routing for radio mode on a
24xxx device.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Report and set correctly converted frequency to/from a V4L2 app.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Frequency units in V4L2 are apparently different when in radio mode
compared to tv mode. Why? Who knows. This change adapts the driver
appropriately - so that internally we always only deal in Hz and don't
have to muck with craziness like this.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
A conversion from Hz to V4L frequency units was accidentally removed
by an earlier change. Restore it.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
We can't allocate v4l device structures in a block, since the v4l core
governs when each device actually gets freed. This bug was introduced
as part of the core radio implementation. Fix it.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Support specification of vbi and radio device minor numbers in a
manner similar to the video device minor number.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Ensure we don't accidentally broadcast the standard while in radio mode.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The initial radio implementation used different units for tuning when
in radio mode. This changes everything to Hz.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Use separate enum for get/store of minor number; we want pvr2_config
to go away eventually and since it really means something different,
don't use it here
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The "main" V4L2 interface patch. This is yet very incomplete, incorrect and
probably inappropriate for inclusion as-is, but at least with this I 'm able
to tune and play radio through a V4L2 program (pvr-radio.c, a "thumb" version
of ivtv-radio.c with just the essentials).
Therefore, it kinda gives an idea of what is needed to support this, hm,
interface (partly used also by e.g., kradio). Please point out any mistakes
on this code. I 'm sure I 'm messing up some struct initialization somewhere
but currently I 'm too lazy to actually think this through until I complete
the functionality (e.g., handle the VIDIOC_S_STD, ENUMINPUT, etc ioctls
appropriately).
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Add (and expose) a new function, pvr2_channel_check_stream_no_lock(), in
pvrusb2-context.c. This is hopefully the last V4L2 interface related patch
to change anything outside pvrusb2-v4l2.c.
We need this to implement the open() for the radio device. The reason is
that within the *enter_context() section of open() we need to ensure nobody
is streaming and if we cannot, we should cleanup after ourselves and return
-EBUSY. We cannot just use claim_stream() because:
1) That would cause a deadlock trying to re-acquire the context lock
2) We only need to ensure that nobody is streaming. We don't need to
actually acquire the stream.
Again, this is a kinda ugly patch. Feel free to improve.
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This is the first patch in preparation of the V4L2/IVTV radio interface.
It does away with the assumption of only one minor per device. It also
adds a file to show the radio minor as well. This can be useful for a
program like pvr-radio.c (when it grows up), since this way it can search
for the minor of the /dev/radioX device it opened and use the video minor
of the same driver instance to get to the actual stream.
The implementation looks kinda ugly. Feel free to improve (that is the
reason behind separate patches anyway).
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
In the previous patch we exploited the get_{min,max}_value facility to adjust
min/max allowable frequencies on the fly, depending on tuner mode.
Unfortunately, this facility was not used inside the *sym_to_val() function
that translates what we echo to sysfs, which means we got an -ERANGE despite
asking for a frequency between what we read to be min/max.
This patch corrects this small omission.
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This is the logic that:
a) Ensures /sys/class/pvrusb2/sn-*/ctl_frequency/{max,min}_val are
"automagically" reset to sane values on each mode change.
b) Allows tuning to a radio frequency by something like:
echo `perl -e "print int(94.9*16000 + 0.5)"` \
> /sys/class/pvrusb2/sn-*/ctl_input/cur_val
The trick was to take advantage of the already existing .get_{min,max}_value
function pointers in pvr2_ctrl, to "dynamically override" the hardcoded values
for min/max frequency at runtime.
For a moment I thought to dispose of the hardcoded MIN/MAX_FREQ and use the
hirange/lowrange fields of the v4l2_tuner struct instead, but then I see that
tuner-core.c kinda hardcodes these as well, so I decided to not bother.
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This is the logic that supports switching modes via e.g.,
echo radio > /sys/class/pvrusb2/sn-*/ctl_input/cur_val.
To do the mode switching we need to:
a) broadcast AUDC_SET_RADIO and
b) issue the CX2341X_ENC_MUTE_VIDEO command to the encoder.
The first is done by adding a new pvr2_i2c_op and having it trigger on
input change, the second by adding this command in pvr2_encoder_start()
and requesting an encoder restart on input change by setting
stale_subsys_mask appropriately.
The clues about AUDC_SET_RADIO and CX2341X_ENC_MUTE_VIDEO were kindly
provided by Hans Verkuil on the pvrusb2 mailing list. The idea to
implement mode switching this way (on input change) is due to Mike Isely.
Why AUDC_SET_RADIO/VIDIOC_S_STD are used for switching? I can 't be sure,
but I think this can be traced to a cornell student being the first to
implement radio support in ivtv "as a different standard". I think the
rest just evolved from there (it 's in the ivtv ML archives).
Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
There are several potential troubles on vivi waitqueue code:
- Watchdog timer should be reset at every received frame;
- Watchdog timer should be reset at the beginning of vivi_thread();
- Checks for errors when creating a newer thread with kernel_thread();
- Wake up vivi_thread() after creating it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
If for some reason vivi_thread() fails, vivi will suffer an OOPS at
thread stop code, since waitqueue wouldn't be properly initializated.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The keymap is based on a previous patch by Jussi Kukkonen.
This remote is identified by subsystem_device id 0x1010.
Signed-off-by: Ville-Pekka Vainio <vpivaini@cs.helsinki.fi>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Bill Dirks asked me to update his entries at kernel files, since
he change his e-mail.
I've also updated a few web broken links or obsolete info to the curent
sites where V4L drivers and API are being discussed currently.
CC: Bill Dirks <bill@thedirks.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
- Add support for SN9C105 and SN9C120
- Add some more USB device identifiers
- Add support for OV7660
- Implement audio ioctl's and VIDIOC_ENUM_FRAMESIZES
- Add preliminary support for 0x0c45/0x6007
- Documentation updates
- Generic improvements
Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>