diff options
author | Mike Isely <isely@pobox.com> | 2007-09-08 21:28:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-10-09 21:14:34 -0400 |
commit | 9f66d4eac6be2428901ab6e0cbb6747d5b6794ef (patch) | |
tree | ff790fe0c5c650dfdd4e202c87397f8497990561 /drivers/media | |
parent | 1d643a372259749ce2029e386ed5760d5d7f8b89 (diff) |
V4L/DVB (6210): pvrusb2: Do a far better job at setting the default initial video standard
The v4l tveeprom logic tells us what video standards are supported by
the hardware, however it doesn't directly tell us what should be the
preferred initial standard. For example "NTSC/NTSC-J" devices are
reported by tveeprom as support NTSC-M and PAL-M, and while that might
be true, in the vast majority of cases NTSC-M is really what the user
is going to want. However the driver previously just arbitrarily
picked the "lowest numbered" standard as the initial default, which in
that case would have been PAL-M. (And making matters more confusing -
this only caused real problems on 24xxx devices because the saa7115 on
29xxx seems to autodetect the right answer anyway.) This change
implements an algorithm that uses the set of "supported" standards as
a hint to decide on the initial standard. This algorithm ONLY comes
into play if the driver isn't specifically told what to do; said
another way - the user can always still change the standard via the
sysfs interface, via the usual V4L methods, or even specified as a
module parameter. The idea here is only to pick a better starting
point if the user (or app) doesn't otherwise do something to set the
standard; otherwise this change has no real impact.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-hdw.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index c8ee379159e2..20dc573bc150 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
@@ -1694,6 +1694,44 @@ static int pvr2_hdw_check_firmware(struct pvr2_hdw *hdw) | |||
1694 | return result == 0; | 1694 | return result == 0; |
1695 | } | 1695 | } |
1696 | 1696 | ||
1697 | struct pvr2_std_hack { | ||
1698 | v4l2_std_id pat; /* Pattern to match */ | ||
1699 | v4l2_std_id msk; /* Which bits we care about */ | ||
1700 | v4l2_std_id std; /* What additional standards or default to set */ | ||
1701 | }; | ||
1702 | |||
1703 | /* This data structure labels specific combinations of standards from | ||
1704 | tveeprom that we'll try to recognize. If we recognize one, then assume | ||
1705 | a specified default standard to use. This is here because tveeprom only | ||
1706 | tells us about available standards not the intended default standard (if | ||
1707 | any) for the device in question. We guess the default based on what has | ||
1708 | been reported as available. Note that this is only for guessing a | ||
1709 | default - which can always be overridden explicitly - and if the user | ||
1710 | has otherwise named a default then that default will always be used in | ||
1711 | place of this table. */ | ||
1712 | const static struct pvr2_std_hack std_eeprom_maps[] = { | ||
1713 | { /* PAL(B/G) */ | ||
1714 | .pat = V4L2_STD_B|V4L2_STD_GH, | ||
1715 | .std = V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_PAL_G, | ||
1716 | }, | ||
1717 | { /* NTSC(M) */ | ||
1718 | .pat = V4L2_STD_MN, | ||
1719 | .std = V4L2_STD_NTSC_M, | ||
1720 | }, | ||
1721 | { /* PAL(I) */ | ||
1722 | .pat = V4L2_STD_PAL_I, | ||
1723 | .std = V4L2_STD_PAL_I, | ||
1724 | }, | ||
1725 | { /* SECAM(L/L') */ | ||
1726 | .pat = V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC, | ||
1727 | .std = V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC, | ||
1728 | }, | ||
1729 | { /* PAL(D/D1/K) */ | ||
1730 | .pat = V4L2_STD_DK, | ||
1731 | .std = V4L2_STD_PAL_D/V4L2_STD_PAL_D1|V4L2_STD_PAL_K, | ||
1732 | }, | ||
1733 | }; | ||
1734 | |||
1697 | static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw) | 1735 | static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw) |
1698 | { | 1736 | { |
1699 | char buf[40]; | 1737 | char buf[40]; |
@@ -1732,6 +1770,27 @@ static void pvr2_hdw_setup_std(struct pvr2_hdw *hdw) | |||
1732 | return; | 1770 | return; |
1733 | } | 1771 | } |
1734 | 1772 | ||
1773 | { | ||
1774 | unsigned int idx; | ||
1775 | for (idx = 0; idx < ARRAY_SIZE(std_eeprom_maps); idx++) { | ||
1776 | if (std_eeprom_maps[idx].msk ? | ||
1777 | ((std_eeprom_maps[idx].pat ^ | ||
1778 | hdw->std_mask_eeprom) & | ||
1779 | std_eeprom_maps[idx].msk) : | ||
1780 | (std_eeprom_maps[idx].pat != | ||
1781 | hdw->std_mask_eeprom)) continue; | ||
1782 | bcnt = pvr2_std_id_to_str(buf,sizeof(buf), | ||
1783 | std_eeprom_maps[idx].std); | ||
1784 | pvr2_trace(PVR2_TRACE_INIT, | ||
1785 | "Initial video standard guessed as %.*s", | ||
1786 | bcnt,buf); | ||
1787 | hdw->std_mask_cur = std_eeprom_maps[idx].std; | ||
1788 | hdw->std_dirty = !0; | ||
1789 | pvr2_hdw_internal_find_stdenum(hdw); | ||
1790 | return; | ||
1791 | } | ||
1792 | } | ||
1793 | |||
1735 | if (hdw->std_enum_cnt > 1) { | 1794 | if (hdw->std_enum_cnt > 1) { |
1736 | // Autoselect the first listed standard | 1795 | // Autoselect the first listed standard |
1737 | hdw->std_enum_cur = 1; | 1796 | hdw->std_enum_cur = 1; |