aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2009-06-20 13:45:52 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-23 02:15:01 -0400
commite17d787c513f41f59969247062561fff6340f211 (patch)
tree3353048a11f1cef8a1861bf378880a8705b3e973 /drivers/media
parentb34cdc36c4aad10cf4eaadacf067835d6a622f1b (diff)
V4L/DVB (12118): pvrusb2: Fix hardware scaling when used with cx25840
The cx25840 module requires that its VBI initialization entry point be called in order for hardware-scaled video capture to work properly - even if we don't care about VBI. Making this behavior even more subtle is that if the capture resolution is set to 720x480 - which is the default that the pvrusb2 driver sets up - then the cx25840 bypasses the hardware scaler. Therefore this problem does not manifest itself until some other resolution, e.g. 640x480, is tried. MythTV typically defaults to 640x480 or 480x480, which means that things break whenever the driver is used with MythTV. This all has been known for a while (since at least Nov 2006), but recent changes in the pvrusb2 driver (specifically in regards to sub-device support) caused this to break again. VBI initialization must happen *after* the chip's firmware is loaded, not before. With this fix, 24xxx devices work correctly again. A related fix that is part of this changeset is that now we re-initialize VBI any time after we issue a reset to the cx25840 driver. Issuing a chip reset erases the state that the VBI setup previously did. Until the HVR-1950 came along this subtlety went unnoticed, because the pvrusb2 driver previously never issued such a reset. But with the HVR-1950 we have to do that reset in order to correctly transition from digital back to analog mode - and since the HVR-1950 always starts in digital mode (required for the DVB side to initialize correctly) then this device has never had a chance to work correctly in analog mode! Analog capture on the HVR-1950 has been broken this *ENTIRE* time. I had missed it until now because I've usually been testing at the default 720x480 resolution which does not require scaling... What fun. By re-initializing VBI after a cx25840 chip reset, correct behavior is restored. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 0c745b142fb7..e97f8e0e466c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1987,6 +1987,34 @@ static unsigned int pvr2_copy_i2c_addr_list(
1987} 1987}
1988 1988
1989 1989
1990static void pvr2_hdw_cx25840_vbi_hack(struct pvr2_hdw *hdw)
1991{
1992 /*
1993 Mike Isely <isely@pobox.com> 19-Nov-2006 - This bit of nuttiness
1994 for cx25840 causes that module to correctly set up its video
1995 scaling. This is really a problem in the cx25840 module itself,
1996 but we work around it here. The problem has not been seen in
1997 ivtv because there VBI is supported and set up. We don't do VBI
1998 here (at least not yet) and thus we never attempted to even set
1999 it up.
2000 */
2001 struct v4l2_format fmt;
2002 if (hdw->decoder_client_id != PVR2_CLIENT_ID_CX25840) {
2003 /* We're not using a cx25840 so don't enable the hack */
2004 return;
2005 }
2006
2007 pvr2_trace(PVR2_TRACE_INIT,
2008 "Module ID %u:"
2009 " Executing cx25840 VBI hack",
2010 hdw->decoder_client_id);
2011 memset(&fmt, 0, sizeof(fmt));
2012 fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
2013 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id,
2014 video, s_fmt, &fmt);
2015}
2016
2017
1990static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, 2018static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
1991 const struct pvr2_device_client_desc *cd) 2019 const struct pvr2_device_client_desc *cd)
1992{ 2020{
@@ -2078,30 +2106,6 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
2078 /* client-specific setup... */ 2106 /* client-specific setup... */
2079 switch (mid) { 2107 switch (mid) {
2080 case PVR2_CLIENT_ID_CX25840: 2108 case PVR2_CLIENT_ID_CX25840:
2081 hdw->decoder_client_id = mid;
2082 {
2083 /*
2084 Mike Isely <isely@pobox.com> 19-Nov-2006 - This
2085 bit of nuttiness for cx25840 causes that module
2086 to correctly set up its video scaling. This is
2087 really a problem in the cx25840 module itself,
2088 but we work around it here. The problem has not
2089 been seen in ivtv because there VBI is supported
2090 and set up. We don't do VBI here (at least not
2091 yet) and thus we never attempted to even set it
2092 up.
2093 */
2094 struct v4l2_format fmt;
2095 pvr2_trace(PVR2_TRACE_INIT,
2096 "Module ID %u:"
2097 " Executing cx25840 VBI hack",
2098 mid);
2099 memset(&fmt, 0, sizeof(fmt));
2100 fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
2101 v4l2_device_call_all(&hdw->v4l2_dev, mid,
2102 video, s_fmt, &fmt);
2103 }
2104 break;
2105 case PVR2_CLIENT_ID_SAA7115: 2109 case PVR2_CLIENT_ID_SAA7115:
2106 hdw->decoder_client_id = mid; 2110 hdw->decoder_client_id = mid;
2107 break; 2111 break;
@@ -2202,6 +2206,8 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw)
2202 cptr->info->set_value(cptr,~0,cptr->info->default_value); 2206 cptr->info->set_value(cptr,~0,cptr->info->default_value);
2203 } 2207 }
2204 2208
2209 pvr2_hdw_cx25840_vbi_hack(hdw);
2210
2205 /* Set up special default values for the television and radio 2211 /* Set up special default values for the television and radio
2206 frequencies here. It's not really important what these defaults 2212 frequencies here. It's not really important what these defaults
2207 are, but I set them to something usable in the Chicago area just 2213 are, but I set them to something usable in the Chicago area just
@@ -4076,6 +4082,7 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
4076 if (hdw->decoder_client_id) { 4082 if (hdw->decoder_client_id) {
4077 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id, 4083 v4l2_device_call_all(&hdw->v4l2_dev, hdw->decoder_client_id,
4078 core, reset, 0); 4084 core, reset, 0);
4085 pvr2_hdw_cx25840_vbi_hack(hdw);
4079 return 0; 4086 return 0;
4080 } 4087 }
4081 pvr2_trace(PVR2_TRACE_INIT, 4088 pvr2_trace(PVR2_TRACE_INIT,