diff options
author | Jean-François Moine <moinejf@free.fr> | 2010-11-12 05:54:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 05:16:42 -0500 |
commit | f8f20188e863dfb43ac53364da0b8865d37c97e2 (patch) | |
tree | 0545ab8b5c5450c10b1467e5c6d872fa4a04c991 /drivers/media | |
parent | 83db76886c0b0a32a0c8d35b4dc3dc1d8f1287d4 (diff) |
[media] gspca - ov519: Propagate errors to higher level
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/ov519.c | 536 | ||||
-rw-r--r-- | drivers/media/video/gspca/w996Xcf.c | 282 |
2 files changed, 327 insertions, 491 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index f6c62be00949..0591ced5d021 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -1869,10 +1869,13 @@ static unsigned char ov7670_abs_to_sm(unsigned char v) | |||
1869 | } | 1869 | } |
1870 | 1870 | ||
1871 | /* Write a OV519 register */ | 1871 | /* Write a OV519 register */ |
1872 | static int reg_w(struct sd *sd, u16 index, u16 value) | 1872 | static void reg_w(struct sd *sd, u16 index, u16 value) |
1873 | { | 1873 | { |
1874 | int ret, req = 0; | 1874 | int ret, req = 0; |
1875 | 1875 | ||
1876 | if (sd->gspca_dev.usb_err < 0) | ||
1877 | return; | ||
1878 | |||
1876 | switch (sd->bridge) { | 1879 | switch (sd->bridge) { |
1877 | case BRIDGE_OV511: | 1880 | case BRIDGE_OV511: |
1878 | case BRIDGE_OV511PLUS: | 1881 | case BRIDGE_OV511PLUS: |
@@ -1903,11 +1906,11 @@ leave: | |||
1903 | if (ret < 0) { | 1906 | if (ret < 0) { |
1904 | err("Write reg 0x%04x -> [0x%02x] failed", | 1907 | err("Write reg 0x%04x -> [0x%02x] failed", |
1905 | value, index); | 1908 | value, index); |
1906 | return ret; | 1909 | sd->gspca_dev.usb_err = ret; |
1910 | return; | ||
1907 | } | 1911 | } |
1908 | 1912 | ||
1909 | PDEBUG(D_USBO, "Write reg 0x%04x -> [0x%02x]", value, index); | 1913 | PDEBUG(D_USBO, "Write reg 0x%04x -> [0x%02x]", value, index); |
1910 | return 0; | ||
1911 | } | 1914 | } |
1912 | 1915 | ||
1913 | /* Read from a OV519 register, note not valid for the w9968cf!! */ | 1916 | /* Read from a OV519 register, note not valid for the w9968cf!! */ |
@@ -1917,6 +1920,9 @@ static int reg_r(struct sd *sd, u16 index) | |||
1917 | int ret; | 1920 | int ret; |
1918 | int req; | 1921 | int req; |
1919 | 1922 | ||
1923 | if (sd->gspca_dev.usb_err < 0) | ||
1924 | return -1; | ||
1925 | |||
1920 | switch (sd->bridge) { | 1926 | switch (sd->bridge) { |
1921 | case BRIDGE_OV511: | 1927 | case BRIDGE_OV511: |
1922 | case BRIDGE_OV511PLUS: | 1928 | case BRIDGE_OV511PLUS: |
@@ -1938,8 +1944,10 @@ static int reg_r(struct sd *sd, u16 index) | |||
1938 | if (ret >= 0) { | 1944 | if (ret >= 0) { |
1939 | ret = sd->gspca_dev.usb_buf[0]; | 1945 | ret = sd->gspca_dev.usb_buf[0]; |
1940 | PDEBUG(D_USBI, "Read reg [0x%02X] -> 0x%04X", index, ret); | 1946 | PDEBUG(D_USBI, "Read reg [0x%02X] -> 0x%04X", index, ret); |
1941 | } else | 1947 | } else { |
1942 | err("Read reg [0x%02x] failed", index); | 1948 | err("Read reg [0x%02x] failed", index); |
1949 | sd->gspca_dev.usb_err = ret; | ||
1950 | } | ||
1943 | 1951 | ||
1944 | return ret; | 1952 | return ret; |
1945 | } | 1953 | } |
@@ -1950,16 +1958,21 @@ static int reg_r8(struct sd *sd, | |||
1950 | { | 1958 | { |
1951 | int ret; | 1959 | int ret; |
1952 | 1960 | ||
1961 | if (sd->gspca_dev.usb_err < 0) | ||
1962 | return -1; | ||
1963 | |||
1953 | ret = usb_control_msg(sd->gspca_dev.dev, | 1964 | ret = usb_control_msg(sd->gspca_dev.dev, |
1954 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), | 1965 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), |
1955 | 1, /* REQ_IO */ | 1966 | 1, /* REQ_IO */ |
1956 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 1967 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
1957 | 0, index, sd->gspca_dev.usb_buf, 8, 500); | 1968 | 0, index, sd->gspca_dev.usb_buf, 8, 500); |
1958 | 1969 | ||
1959 | if (ret >= 0) | 1970 | if (ret >= 0) { |
1960 | ret = sd->gspca_dev.usb_buf[0]; | 1971 | ret = sd->gspca_dev.usb_buf[0]; |
1961 | else | 1972 | } else { |
1962 | err("Read reg 8 [0x%02x] failed", index); | 1973 | err("Read reg 8 [0x%02x] failed", index); |
1974 | sd->gspca_dev.usb_err = ret; | ||
1975 | } | ||
1963 | 1976 | ||
1964 | return ret; | 1977 | return ret; |
1965 | } | 1978 | } |
@@ -1970,7 +1983,7 @@ static int reg_r8(struct sd *sd, | |||
1970 | * that are in the same position as 0's in "mask" are preserved, regardless | 1983 | * that are in the same position as 0's in "mask" are preserved, regardless |
1971 | * of their respective state in "value". | 1984 | * of their respective state in "value". |
1972 | */ | 1985 | */ |
1973 | static int reg_w_mask(struct sd *sd, | 1986 | static void reg_w_mask(struct sd *sd, |
1974 | u16 index, | 1987 | u16 index, |
1975 | u8 value, | 1988 | u8 value, |
1976 | u8 mask) | 1989 | u8 mask) |
@@ -1982,22 +1995,25 @@ static int reg_w_mask(struct sd *sd, | |||
1982 | value &= mask; /* Enforce mask on value */ | 1995 | value &= mask; /* Enforce mask on value */ |
1983 | ret = reg_r(sd, index); | 1996 | ret = reg_r(sd, index); |
1984 | if (ret < 0) | 1997 | if (ret < 0) |
1985 | return ret; | 1998 | return; |
1986 | 1999 | ||
1987 | oldval = ret & ~mask; /* Clear the masked bits */ | 2000 | oldval = ret & ~mask; /* Clear the masked bits */ |
1988 | value |= oldval; /* Set the desired bits */ | 2001 | value |= oldval; /* Set the desired bits */ |
1989 | } | 2002 | } |
1990 | return reg_w(sd, index, value); | 2003 | reg_w(sd, index, value); |
1991 | } | 2004 | } |
1992 | 2005 | ||
1993 | /* | 2006 | /* |
1994 | * Writes multiple (n) byte value to a single register. Only valid with certain | 2007 | * Writes multiple (n) byte value to a single register. Only valid with certain |
1995 | * registers (0x30 and 0xc4 - 0xce). | 2008 | * registers (0x30 and 0xc4 - 0xce). |
1996 | */ | 2009 | */ |
1997 | static int ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) | 2010 | static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) |
1998 | { | 2011 | { |
1999 | int ret; | 2012 | int ret; |
2000 | 2013 | ||
2014 | if (sd->gspca_dev.usb_err < 0) | ||
2015 | return; | ||
2016 | |||
2001 | *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); | 2017 | *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); |
2002 | 2018 | ||
2003 | ret = usb_control_msg(sd->gspca_dev.dev, | 2019 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -2008,13 +2024,11 @@ static int ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) | |||
2008 | sd->gspca_dev.usb_buf, n, 500); | 2024 | sd->gspca_dev.usb_buf, n, 500); |
2009 | if (ret < 0) { | 2025 | if (ret < 0) { |
2010 | err("Write reg32 [%02x] %08x failed", index, value); | 2026 | err("Write reg32 [%02x] %08x failed", index, value); |
2011 | return ret; | 2027 | sd->gspca_dev.usb_err = ret; |
2012 | } | 2028 | } |
2013 | |||
2014 | return 0; | ||
2015 | } | 2029 | } |
2016 | 2030 | ||
2017 | static int ov511_i2c_w(struct sd *sd, u8 reg, u8 value) | 2031 | static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) |
2018 | { | 2032 | { |
2019 | int rc, retries; | 2033 | int rc, retries; |
2020 | 2034 | ||
@@ -2023,36 +2037,28 @@ static int ov511_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
2023 | /* Three byte write cycle */ | 2037 | /* Three byte write cycle */ |
2024 | for (retries = 6; ; ) { | 2038 | for (retries = 6; ; ) { |
2025 | /* Select camera register */ | 2039 | /* Select camera register */ |
2026 | rc = reg_w(sd, R51x_I2C_SADDR_3, reg); | 2040 | reg_w(sd, R51x_I2C_SADDR_3, reg); |
2027 | if (rc < 0) | ||
2028 | return rc; | ||
2029 | 2041 | ||
2030 | /* Write "value" to I2C data port of OV511 */ | 2042 | /* Write "value" to I2C data port of OV511 */ |
2031 | rc = reg_w(sd, R51x_I2C_DATA, value); | 2043 | reg_w(sd, R51x_I2C_DATA, value); |
2032 | if (rc < 0) | ||
2033 | return rc; | ||
2034 | 2044 | ||
2035 | /* Initiate 3-byte write cycle */ | 2045 | /* Initiate 3-byte write cycle */ |
2036 | rc = reg_w(sd, R511_I2C_CTL, 0x01); | 2046 | reg_w(sd, R511_I2C_CTL, 0x01); |
2037 | if (rc < 0) | ||
2038 | return rc; | ||
2039 | 2047 | ||
2040 | do { | 2048 | do { |
2041 | rc = reg_r(sd, R511_I2C_CTL); | 2049 | rc = reg_r(sd, R511_I2C_CTL); |
2042 | } while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ | 2050 | } while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */ |
2043 | 2051 | ||
2044 | if (rc < 0) | 2052 | if (rc < 0) |
2045 | return rc; | 2053 | return; |
2046 | 2054 | ||
2047 | if ((rc & 2) == 0) /* Ack? */ | 2055 | if ((rc & 2) == 0) /* Ack? */ |
2048 | break; | 2056 | break; |
2049 | if (--retries < 0) { | 2057 | if (--retries < 0) { |
2050 | PDEBUG(D_USBO, "i2c write retries exhausted"); | 2058 | PDEBUG(D_USBO, "i2c write retries exhausted"); |
2051 | return -1; | 2059 | return; |
2052 | } | 2060 | } |
2053 | } | 2061 | } |
2054 | |||
2055 | return 0; | ||
2056 | } | 2062 | } |
2057 | 2063 | ||
2058 | static int ov511_i2c_r(struct sd *sd, u8 reg) | 2064 | static int ov511_i2c_r(struct sd *sd, u8 reg) |
@@ -2062,14 +2068,10 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) | |||
2062 | /* Two byte write cycle */ | 2068 | /* Two byte write cycle */ |
2063 | for (retries = 6; ; ) { | 2069 | for (retries = 6; ; ) { |
2064 | /* Select camera register */ | 2070 | /* Select camera register */ |
2065 | rc = reg_w(sd, R51x_I2C_SADDR_2, reg); | 2071 | reg_w(sd, R51x_I2C_SADDR_2, reg); |
2066 | if (rc < 0) | ||
2067 | return rc; | ||
2068 | 2072 | ||
2069 | /* Initiate 2-byte write cycle */ | 2073 | /* Initiate 2-byte write cycle */ |
2070 | rc = reg_w(sd, R511_I2C_CTL, 0x03); | 2074 | reg_w(sd, R511_I2C_CTL, 0x03); |
2071 | if (rc < 0) | ||
2072 | return rc; | ||
2073 | 2075 | ||
2074 | do { | 2076 | do { |
2075 | rc = reg_r(sd, R511_I2C_CTL); | 2077 | rc = reg_r(sd, R511_I2C_CTL); |
@@ -2093,9 +2095,7 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) | |||
2093 | /* Two byte read cycle */ | 2095 | /* Two byte read cycle */ |
2094 | for (retries = 6; ; ) { | 2096 | for (retries = 6; ; ) { |
2095 | /* Initiate 2-byte read cycle */ | 2097 | /* Initiate 2-byte read cycle */ |
2096 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | 2098 | reg_w(sd, R511_I2C_CTL, 0x05); |
2097 | if (rc < 0) | ||
2098 | return rc; | ||
2099 | 2099 | ||
2100 | do { | 2100 | do { |
2101 | rc = reg_r(sd, R511_I2C_CTL); | 2101 | rc = reg_r(sd, R511_I2C_CTL); |
@@ -2108,9 +2108,7 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) | |||
2108 | break; | 2108 | break; |
2109 | 2109 | ||
2110 | /* I2C abort */ | 2110 | /* I2C abort */ |
2111 | rc = reg_w(sd, R511_I2C_CTL, 0x10); | 2111 | reg_w(sd, R511_I2C_CTL, 0x10); |
2112 | if (rc < 0) | ||
2113 | return rc; | ||
2114 | 2112 | ||
2115 | if (--retries < 0) { | 2113 | if (--retries < 0) { |
2116 | PDEBUG(D_USBI, "i2c read retries exhausted"); | 2114 | PDEBUG(D_USBI, "i2c read retries exhausted"); |
@@ -2123,9 +2121,7 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) | |||
2123 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 2121 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); |
2124 | 2122 | ||
2125 | /* This is needed to make i2c_w() work */ | 2123 | /* This is needed to make i2c_w() work */ |
2126 | rc = reg_w(sd, R511_I2C_CTL, 0x05); | 2124 | reg_w(sd, R511_I2C_CTL, 0x05); |
2127 | if (rc < 0) | ||
2128 | return rc; | ||
2129 | 2125 | ||
2130 | return value; | 2126 | return value; |
2131 | } | 2127 | } |
@@ -2135,32 +2131,24 @@ static int ov511_i2c_r(struct sd *sd, u8 reg) | |||
2135 | * This is normally only called from i2c_w(). Note that this function | 2131 | * This is normally only called from i2c_w(). Note that this function |
2136 | * always succeeds regardless of whether the sensor is present and working. | 2132 | * always succeeds regardless of whether the sensor is present and working. |
2137 | */ | 2133 | */ |
2138 | static int ov518_i2c_w(struct sd *sd, | 2134 | static void ov518_i2c_w(struct sd *sd, |
2139 | u8 reg, | 2135 | u8 reg, |
2140 | u8 value) | 2136 | u8 value) |
2141 | { | 2137 | { |
2142 | int rc; | ||
2143 | |||
2144 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | 2138 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); |
2145 | 2139 | ||
2146 | /* Select camera register */ | 2140 | /* Select camera register */ |
2147 | rc = reg_w(sd, R51x_I2C_SADDR_3, reg); | 2141 | reg_w(sd, R51x_I2C_SADDR_3, reg); |
2148 | if (rc < 0) | ||
2149 | return rc; | ||
2150 | 2142 | ||
2151 | /* Write "value" to I2C data port of OV511 */ | 2143 | /* Write "value" to I2C data port of OV511 */ |
2152 | rc = reg_w(sd, R51x_I2C_DATA, value); | 2144 | reg_w(sd, R51x_I2C_DATA, value); |
2153 | if (rc < 0) | ||
2154 | return rc; | ||
2155 | 2145 | ||
2156 | /* Initiate 3-byte write cycle */ | 2146 | /* Initiate 3-byte write cycle */ |
2157 | rc = reg_w(sd, R518_I2C_CTL, 0x01); | 2147 | reg_w(sd, R518_I2C_CTL, 0x01); |
2158 | if (rc < 0) | ||
2159 | return rc; | ||
2160 | 2148 | ||
2161 | /* wait for write complete */ | 2149 | /* wait for write complete */ |
2162 | msleep(4); | 2150 | msleep(4); |
2163 | return reg_r8(sd, R518_I2C_CTL); | 2151 | reg_r8(sd, R518_I2C_CTL); |
2164 | } | 2152 | } |
2165 | 2153 | ||
2166 | /* | 2154 | /* |
@@ -2172,31 +2160,28 @@ static int ov518_i2c_w(struct sd *sd, | |||
2172 | */ | 2160 | */ |
2173 | static int ov518_i2c_r(struct sd *sd, u8 reg) | 2161 | static int ov518_i2c_r(struct sd *sd, u8 reg) |
2174 | { | 2162 | { |
2175 | int rc, value; | 2163 | int value; |
2176 | 2164 | ||
2177 | /* Select camera register */ | 2165 | /* Select camera register */ |
2178 | rc = reg_w(sd, R51x_I2C_SADDR_2, reg); | 2166 | reg_w(sd, R51x_I2C_SADDR_2, reg); |
2179 | if (rc < 0) | ||
2180 | return rc; | ||
2181 | 2167 | ||
2182 | /* Initiate 2-byte write cycle */ | 2168 | /* Initiate 2-byte write cycle */ |
2183 | rc = reg_w(sd, R518_I2C_CTL, 0x03); | 2169 | reg_w(sd, R518_I2C_CTL, 0x03); |
2184 | if (rc < 0) | ||
2185 | return rc; | ||
2186 | 2170 | ||
2187 | /* Initiate 2-byte read cycle */ | 2171 | /* Initiate 2-byte read cycle */ |
2188 | rc = reg_w(sd, R518_I2C_CTL, 0x05); | 2172 | reg_w(sd, R518_I2C_CTL, 0x05); |
2189 | if (rc < 0) | ||
2190 | return rc; | ||
2191 | value = reg_r(sd, R51x_I2C_DATA); | 2173 | value = reg_r(sd, R51x_I2C_DATA); |
2192 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 2174 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); |
2193 | return value; | 2175 | return value; |
2194 | } | 2176 | } |
2195 | 2177 | ||
2196 | static int ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) | 2178 | static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) |
2197 | { | 2179 | { |
2198 | int ret; | 2180 | int ret; |
2199 | 2181 | ||
2182 | if (sd->gspca_dev.usb_err < 0) | ||
2183 | return; | ||
2184 | |||
2200 | ret = usb_control_msg(sd->gspca_dev.dev, | 2185 | ret = usb_control_msg(sd->gspca_dev.dev, |
2201 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), | 2186 | usb_sndctrlpipe(sd->gspca_dev.dev, 0), |
2202 | 0x02, | 2187 | 0x02, |
@@ -2205,17 +2190,19 @@ static int ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
2205 | 2190 | ||
2206 | if (ret < 0) { | 2191 | if (ret < 0) { |
2207 | err("i2c 0x%02x -> [0x%02x] failed", value, reg); | 2192 | err("i2c 0x%02x -> [0x%02x] failed", value, reg); |
2208 | return ret; | 2193 | sd->gspca_dev.usb_err = ret; |
2209 | } | 2194 | } |
2210 | 2195 | ||
2211 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | 2196 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); |
2212 | return 0; | ||
2213 | } | 2197 | } |
2214 | 2198 | ||
2215 | static int ovfx2_i2c_r(struct sd *sd, u8 reg) | 2199 | static int ovfx2_i2c_r(struct sd *sd, u8 reg) |
2216 | { | 2200 | { |
2217 | int ret; | 2201 | int ret; |
2218 | 2202 | ||
2203 | if (sd->gspca_dev.usb_err < 0) | ||
2204 | return -1; | ||
2205 | |||
2219 | ret = usb_control_msg(sd->gspca_dev.dev, | 2206 | ret = usb_control_msg(sd->gspca_dev.dev, |
2220 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), | 2207 | usb_rcvctrlpipe(sd->gspca_dev.dev, 0), |
2221 | 0x03, | 2208 | 0x03, |
@@ -2225,38 +2212,38 @@ static int ovfx2_i2c_r(struct sd *sd, u8 reg) | |||
2225 | if (ret >= 0) { | 2212 | if (ret >= 0) { |
2226 | ret = sd->gspca_dev.usb_buf[0]; | 2213 | ret = sd->gspca_dev.usb_buf[0]; |
2227 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, ret); | 2214 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, ret); |
2228 | } else | 2215 | } else { |
2229 | err("i2c read [0x%02x] failed", reg); | 2216 | err("i2c read [0x%02x] failed", reg); |
2217 | sd->gspca_dev.usb_err = ret; | ||
2218 | } | ||
2230 | 2219 | ||
2231 | return ret; | 2220 | return ret; |
2232 | } | 2221 | } |
2233 | 2222 | ||
2234 | static int i2c_w(struct sd *sd, u8 reg, u8 value) | 2223 | static void i2c_w(struct sd *sd, u8 reg, u8 value) |
2235 | { | 2224 | { |
2236 | int ret = -1; | ||
2237 | |||
2238 | if (sd->sensor_reg_cache[reg] == value) | 2225 | if (sd->sensor_reg_cache[reg] == value) |
2239 | return 0; | 2226 | return; |
2240 | 2227 | ||
2241 | switch (sd->bridge) { | 2228 | switch (sd->bridge) { |
2242 | case BRIDGE_OV511: | 2229 | case BRIDGE_OV511: |
2243 | case BRIDGE_OV511PLUS: | 2230 | case BRIDGE_OV511PLUS: |
2244 | ret = ov511_i2c_w(sd, reg, value); | 2231 | ov511_i2c_w(sd, reg, value); |
2245 | break; | 2232 | break; |
2246 | case BRIDGE_OV518: | 2233 | case BRIDGE_OV518: |
2247 | case BRIDGE_OV518PLUS: | 2234 | case BRIDGE_OV518PLUS: |
2248 | case BRIDGE_OV519: | 2235 | case BRIDGE_OV519: |
2249 | ret = ov518_i2c_w(sd, reg, value); | 2236 | ov518_i2c_w(sd, reg, value); |
2250 | break; | 2237 | break; |
2251 | case BRIDGE_OVFX2: | 2238 | case BRIDGE_OVFX2: |
2252 | ret = ovfx2_i2c_w(sd, reg, value); | 2239 | ovfx2_i2c_w(sd, reg, value); |
2253 | break; | 2240 | break; |
2254 | case BRIDGE_W9968CF: | 2241 | case BRIDGE_W9968CF: |
2255 | ret = w9968cf_i2c_w(sd, reg, value); | 2242 | w9968cf_i2c_w(sd, reg, value); |
2256 | break; | 2243 | break; |
2257 | } | 2244 | } |
2258 | 2245 | ||
2259 | if (ret >= 0) { | 2246 | if (sd->gspca_dev.usb_err >= 0) { |
2260 | /* Up on sensor reset empty the register cache */ | 2247 | /* Up on sensor reset empty the register cache */ |
2261 | if (reg == 0x12 && (value & 0x80)) | 2248 | if (reg == 0x12 && (value & 0x80)) |
2262 | memset(sd->sensor_reg_cache, -1, | 2249 | memset(sd->sensor_reg_cache, -1, |
@@ -2264,8 +2251,6 @@ static int i2c_w(struct sd *sd, u8 reg, u8 value) | |||
2264 | else | 2251 | else |
2265 | sd->sensor_reg_cache[reg] = value; | 2252 | sd->sensor_reg_cache[reg] = value; |
2266 | } | 2253 | } |
2267 | |||
2268 | return ret; | ||
2269 | } | 2254 | } |
2270 | 2255 | ||
2271 | static int i2c_r(struct sd *sd, u8 reg) | 2256 | static int i2c_r(struct sd *sd, u8 reg) |
@@ -2304,7 +2289,7 @@ static int i2c_r(struct sd *sd, u8 reg) | |||
2304 | * that are in the same position as 0's in "mask" are preserved, regardless | 2289 | * that are in the same position as 0's in "mask" are preserved, regardless |
2305 | * of their respective state in "value". | 2290 | * of their respective state in "value". |
2306 | */ | 2291 | */ |
2307 | static int i2c_w_mask(struct sd *sd, | 2292 | static void i2c_w_mask(struct sd *sd, |
2308 | u8 reg, | 2293 | u8 reg, |
2309 | u8 value, | 2294 | u8 value, |
2310 | u8 mask) | 2295 | u8 mask) |
@@ -2315,70 +2300,72 @@ static int i2c_w_mask(struct sd *sd, | |||
2315 | value &= mask; /* Enforce mask on value */ | 2300 | value &= mask; /* Enforce mask on value */ |
2316 | rc = i2c_r(sd, reg); | 2301 | rc = i2c_r(sd, reg); |
2317 | if (rc < 0) | 2302 | if (rc < 0) |
2318 | return rc; | 2303 | return; |
2319 | oldval = rc & ~mask; /* Clear the masked bits */ | 2304 | oldval = rc & ~mask; /* Clear the masked bits */ |
2320 | value |= oldval; /* Set the desired bits */ | 2305 | value |= oldval; /* Set the desired bits */ |
2321 | return i2c_w(sd, reg, value); | 2306 | i2c_w(sd, reg, value); |
2322 | } | 2307 | } |
2323 | 2308 | ||
2324 | /* Temporarily stops OV511 from functioning. Must do this before changing | 2309 | /* Temporarily stops OV511 from functioning. Must do this before changing |
2325 | * registers while the camera is streaming */ | 2310 | * registers while the camera is streaming */ |
2326 | static inline int ov51x_stop(struct sd *sd) | 2311 | static inline void ov51x_stop(struct sd *sd) |
2327 | { | 2312 | { |
2328 | PDEBUG(D_STREAM, "stopping"); | 2313 | PDEBUG(D_STREAM, "stopping"); |
2329 | sd->stopped = 1; | 2314 | sd->stopped = 1; |
2330 | switch (sd->bridge) { | 2315 | switch (sd->bridge) { |
2331 | case BRIDGE_OV511: | 2316 | case BRIDGE_OV511: |
2332 | case BRIDGE_OV511PLUS: | 2317 | case BRIDGE_OV511PLUS: |
2333 | return reg_w(sd, R51x_SYS_RESET, 0x3d); | 2318 | reg_w(sd, R51x_SYS_RESET, 0x3d); |
2319 | break; | ||
2334 | case BRIDGE_OV518: | 2320 | case BRIDGE_OV518: |
2335 | case BRIDGE_OV518PLUS: | 2321 | case BRIDGE_OV518PLUS: |
2336 | return reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a); | 2322 | reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a); |
2323 | break; | ||
2337 | case BRIDGE_OV519: | 2324 | case BRIDGE_OV519: |
2338 | return reg_w(sd, OV519_R51_RESET1, 0x0f); | 2325 | reg_w(sd, OV519_R51_RESET1, 0x0f); |
2326 | break; | ||
2339 | case BRIDGE_OVFX2: | 2327 | case BRIDGE_OVFX2: |
2340 | return reg_w_mask(sd, 0x0f, 0x00, 0x02); | 2328 | reg_w_mask(sd, 0x0f, 0x00, 0x02); |
2329 | break; | ||
2341 | case BRIDGE_W9968CF: | 2330 | case BRIDGE_W9968CF: |
2342 | return reg_w(sd, 0x3c, 0x0a05); /* stop USB transfer */ | 2331 | reg_w(sd, 0x3c, 0x0a05); /* stop USB transfer */ |
2332 | break; | ||
2343 | } | 2333 | } |
2344 | |||
2345 | return 0; | ||
2346 | } | 2334 | } |
2347 | 2335 | ||
2348 | /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not | 2336 | /* Restarts OV511 after ov511_stop() is called. Has no effect if it is not |
2349 | * actually stopped (for performance). */ | 2337 | * actually stopped (for performance). */ |
2350 | static inline int ov51x_restart(struct sd *sd) | 2338 | static inline void ov51x_restart(struct sd *sd) |
2351 | { | 2339 | { |
2352 | int rc; | ||
2353 | |||
2354 | PDEBUG(D_STREAM, "restarting"); | 2340 | PDEBUG(D_STREAM, "restarting"); |
2355 | if (!sd->stopped) | 2341 | if (!sd->stopped) |
2356 | return 0; | 2342 | return; |
2357 | sd->stopped = 0; | 2343 | sd->stopped = 0; |
2358 | 2344 | ||
2359 | /* Reinitialize the stream */ | 2345 | /* Reinitialize the stream */ |
2360 | switch (sd->bridge) { | 2346 | switch (sd->bridge) { |
2361 | case BRIDGE_OV511: | 2347 | case BRIDGE_OV511: |
2362 | case BRIDGE_OV511PLUS: | 2348 | case BRIDGE_OV511PLUS: |
2363 | return reg_w(sd, R51x_SYS_RESET, 0x00); | 2349 | reg_w(sd, R51x_SYS_RESET, 0x00); |
2350 | break; | ||
2364 | case BRIDGE_OV518: | 2351 | case BRIDGE_OV518: |
2365 | case BRIDGE_OV518PLUS: | 2352 | case BRIDGE_OV518PLUS: |
2366 | rc = reg_w(sd, 0x2f, 0x80); | 2353 | reg_w(sd, 0x2f, 0x80); |
2367 | if (rc < 0) | 2354 | reg_w(sd, R51x_SYS_RESET, 0x00); |
2368 | return rc; | 2355 | break; |
2369 | return reg_w(sd, R51x_SYS_RESET, 0x00); | ||
2370 | case BRIDGE_OV519: | 2356 | case BRIDGE_OV519: |
2371 | return reg_w(sd, OV519_R51_RESET1, 0x00); | 2357 | reg_w(sd, OV519_R51_RESET1, 0x00); |
2358 | break; | ||
2372 | case BRIDGE_OVFX2: | 2359 | case BRIDGE_OVFX2: |
2373 | return reg_w_mask(sd, 0x0f, 0x02, 0x02); | 2360 | reg_w_mask(sd, 0x0f, 0x02, 0x02); |
2361 | break; | ||
2374 | case BRIDGE_W9968CF: | 2362 | case BRIDGE_W9968CF: |
2375 | return reg_w(sd, 0x3c, 0x8a05); /* USB FIFO enable */ | 2363 | reg_w(sd, 0x3c, 0x8a05); /* USB FIFO enable */ |
2364 | break; | ||
2376 | } | 2365 | } |
2377 | |||
2378 | return 0; | ||
2379 | } | 2366 | } |
2380 | 2367 | ||
2381 | static int ov51x_set_slave_ids(struct sd *sd, u8 slave); | 2368 | static void ov51x_set_slave_ids(struct sd *sd, u8 slave); |
2382 | 2369 | ||
2383 | /* This does an initial reset of an OmniVision sensor and ensures that I2C | 2370 | /* This does an initial reset of an OmniVision sensor and ensures that I2C |
2384 | * is synchronized. Returns <0 on failure. | 2371 | * is synchronized. Returns <0 on failure. |
@@ -2387,12 +2374,10 @@ static int init_ov_sensor(struct sd *sd, u8 slave) | |||
2387 | { | 2374 | { |
2388 | int i; | 2375 | int i; |
2389 | 2376 | ||
2390 | if (ov51x_set_slave_ids(sd, slave) < 0) | 2377 | ov51x_set_slave_ids(sd, slave); |
2391 | return -EIO; | ||
2392 | 2378 | ||
2393 | /* Reset the sensor */ | 2379 | /* Reset the sensor */ |
2394 | if (i2c_w(sd, 0x12, 0x80) < 0) | 2380 | i2c_w(sd, 0x12, 0x80); |
2395 | return -EIO; | ||
2396 | 2381 | ||
2397 | /* Wait for it to initialize */ | 2382 | /* Wait for it to initialize */ |
2398 | msleep(150); | 2383 | msleep(150); |
@@ -2405,16 +2390,16 @@ static int init_ov_sensor(struct sd *sd, u8 slave) | |||
2405 | } | 2390 | } |
2406 | 2391 | ||
2407 | /* Reset the sensor */ | 2392 | /* Reset the sensor */ |
2408 | if (i2c_w(sd, 0x12, 0x80) < 0) | 2393 | i2c_w(sd, 0x12, 0x80); |
2409 | return -EIO; | 2394 | |
2410 | /* Wait for it to initialize */ | 2395 | /* Wait for it to initialize */ |
2411 | msleep(150); | 2396 | msleep(150); |
2412 | 2397 | ||
2413 | /* Dummy read to sync I2C */ | 2398 | /* Dummy read to sync I2C */ |
2414 | if (i2c_r(sd, 0x00) < 0) | 2399 | if (i2c_r(sd, 0x00) < 0) |
2415 | return -EIO; | 2400 | return -1; |
2416 | } | 2401 | } |
2417 | return -EIO; | 2402 | return -1; |
2418 | } | 2403 | } |
2419 | 2404 | ||
2420 | /* Set the read and write slave IDs. The "slave" argument is the write slave, | 2405 | /* Set the read and write slave IDs. The "slave" argument is the write slave, |
@@ -2422,53 +2407,40 @@ static int init_ov_sensor(struct sd *sd, u8 slave) | |||
2422 | * This should not be called from outside the i2c I/O functions. | 2407 | * This should not be called from outside the i2c I/O functions. |
2423 | * Sets I2C read and write slave IDs. Returns <0 for error | 2408 | * Sets I2C read and write slave IDs. Returns <0 for error |
2424 | */ | 2409 | */ |
2425 | static int ov51x_set_slave_ids(struct sd *sd, | 2410 | static void ov51x_set_slave_ids(struct sd *sd, |
2426 | u8 slave) | 2411 | u8 slave) |
2427 | { | 2412 | { |
2428 | int rc; | ||
2429 | |||
2430 | switch (sd->bridge) { | 2413 | switch (sd->bridge) { |
2431 | case BRIDGE_OVFX2: | 2414 | case BRIDGE_OVFX2: |
2432 | return reg_w(sd, OVFX2_I2C_ADDR, slave); | 2415 | reg_w(sd, OVFX2_I2C_ADDR, slave); |
2416 | return; | ||
2433 | case BRIDGE_W9968CF: | 2417 | case BRIDGE_W9968CF: |
2434 | sd->sensor_addr = slave; | 2418 | sd->sensor_addr = slave; |
2435 | return 0; | 2419 | return; |
2436 | } | 2420 | } |
2437 | 2421 | ||
2438 | rc = reg_w(sd, R51x_I2C_W_SID, slave); | 2422 | reg_w(sd, R51x_I2C_W_SID, slave); |
2439 | if (rc < 0) | 2423 | reg_w(sd, R51x_I2C_R_SID, slave + 1); |
2440 | return rc; | ||
2441 | return reg_w(sd, R51x_I2C_R_SID, slave + 1); | ||
2442 | } | 2424 | } |
2443 | 2425 | ||
2444 | static int write_regvals(struct sd *sd, | 2426 | static void write_regvals(struct sd *sd, |
2445 | const struct ov_regvals *regvals, | 2427 | const struct ov_regvals *regvals, |
2446 | int n) | 2428 | int n) |
2447 | { | 2429 | { |
2448 | int rc; | ||
2449 | |||
2450 | while (--n >= 0) { | 2430 | while (--n >= 0) { |
2451 | rc = reg_w(sd, regvals->reg, regvals->val); | 2431 | reg_w(sd, regvals->reg, regvals->val); |
2452 | if (rc < 0) | ||
2453 | return rc; | ||
2454 | regvals++; | 2432 | regvals++; |
2455 | } | 2433 | } |
2456 | return 0; | ||
2457 | } | 2434 | } |
2458 | 2435 | ||
2459 | static int write_i2c_regvals(struct sd *sd, | 2436 | static void write_i2c_regvals(struct sd *sd, |
2460 | const struct ov_i2c_regvals *regvals, | 2437 | const struct ov_i2c_regvals *regvals, |
2461 | int n) | 2438 | int n) |
2462 | { | 2439 | { |
2463 | int rc; | ||
2464 | |||
2465 | while (--n >= 0) { | 2440 | while (--n >= 0) { |
2466 | rc = i2c_w(sd, regvals->reg, regvals->val); | 2441 | i2c_w(sd, regvals->reg, regvals->val); |
2467 | if (rc < 0) | ||
2468 | return rc; | ||
2469 | regvals++; | 2442 | regvals++; |
2470 | } | 2443 | } |
2471 | return 0; | ||
2472 | } | 2444 | } |
2473 | 2445 | ||
2474 | /**************************************************************************** | 2446 | /**************************************************************************** |
@@ -2478,13 +2450,13 @@ static int write_i2c_regvals(struct sd *sd, | |||
2478 | ***************************************************************************/ | 2450 | ***************************************************************************/ |
2479 | 2451 | ||
2480 | /* This initializes the OV2x10 / OV3610 / OV3620 */ | 2452 | /* This initializes the OV2x10 / OV3610 / OV3620 */ |
2481 | static int ov_hires_configure(struct sd *sd) | 2453 | static void ov_hires_configure(struct sd *sd) |
2482 | { | 2454 | { |
2483 | int high, low; | 2455 | int high, low; |
2484 | 2456 | ||
2485 | if (sd->bridge != BRIDGE_OVFX2) { | 2457 | if (sd->bridge != BRIDGE_OVFX2) { |
2486 | err("error hires sensors only supported with ovfx2"); | 2458 | err("error hires sensors only supported with ovfx2"); |
2487 | return -1; | 2459 | return; |
2488 | } | 2460 | } |
2489 | 2461 | ||
2490 | PDEBUG(D_PROBE, "starting ov hires configuration"); | 2462 | PDEBUG(D_PROBE, "starting ov hires configuration"); |
@@ -2502,18 +2474,13 @@ static int ov_hires_configure(struct sd *sd) | |||
2502 | } else { | 2474 | } else { |
2503 | err("Error unknown sensor type: 0x%02x%02x", | 2475 | err("Error unknown sensor type: 0x%02x%02x", |
2504 | high, low); | 2476 | high, low); |
2505 | return -1; | ||
2506 | } | 2477 | } |
2507 | |||
2508 | /* Set sensor-specific vars */ | ||
2509 | return 0; | ||
2510 | } | 2478 | } |
2511 | 2479 | ||
2512 | |||
2513 | /* This initializes the OV8110, OV8610 sensor. The OV8110 uses | 2480 | /* This initializes the OV8110, OV8610 sensor. The OV8110 uses |
2514 | * the same register settings as the OV8610, since they are very similar. | 2481 | * the same register settings as the OV8610, since they are very similar. |
2515 | */ | 2482 | */ |
2516 | static int ov8xx0_configure(struct sd *sd) | 2483 | static void ov8xx0_configure(struct sd *sd) |
2517 | { | 2484 | { |
2518 | int rc; | 2485 | int rc; |
2519 | 2486 | ||
@@ -2523,23 +2490,18 @@ static int ov8xx0_configure(struct sd *sd) | |||
2523 | rc = i2c_r(sd, OV7610_REG_COM_I); | 2490 | rc = i2c_r(sd, OV7610_REG_COM_I); |
2524 | if (rc < 0) { | 2491 | if (rc < 0) { |
2525 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2492 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2526 | return -1; | 2493 | return; |
2527 | } | 2494 | } |
2528 | if ((rc & 3) == 1) { | 2495 | if ((rc & 3) == 1) |
2529 | sd->sensor = SEN_OV8610; | 2496 | sd->sensor = SEN_OV8610; |
2530 | } else { | 2497 | else |
2531 | err("Unknown image sensor version: %d", rc & 3); | 2498 | err("Unknown image sensor version: %d", rc & 3); |
2532 | return -1; | ||
2533 | } | ||
2534 | |||
2535 | /* Set sensor-specific vars */ | ||
2536 | return 0; | ||
2537 | } | 2499 | } |
2538 | 2500 | ||
2539 | /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses | 2501 | /* This initializes the OV7610, OV7620, or OV76BE sensor. The OV76BE uses |
2540 | * the same register settings as the OV7610, since they are very similar. | 2502 | * the same register settings as the OV7610, since they are very similar. |
2541 | */ | 2503 | */ |
2542 | static int ov7xx0_configure(struct sd *sd) | 2504 | static void ov7xx0_configure(struct sd *sd) |
2543 | { | 2505 | { |
2544 | int rc, high, low; | 2506 | int rc, high, low; |
2545 | 2507 | ||
@@ -2552,7 +2514,7 @@ static int ov7xx0_configure(struct sd *sd) | |||
2552 | * it appears to be wrongly detected as a 7610 by default */ | 2514 | * it appears to be wrongly detected as a 7610 by default */ |
2553 | if (rc < 0) { | 2515 | if (rc < 0) { |
2554 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2516 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2555 | return -1; | 2517 | return; |
2556 | } | 2518 | } |
2557 | if ((rc & 3) == 3) { | 2519 | if ((rc & 3) == 3) { |
2558 | /* quick hack to make OV7670s work */ | 2520 | /* quick hack to make OV7670s work */ |
@@ -2580,19 +2542,19 @@ static int ov7xx0_configure(struct sd *sd) | |||
2580 | high = i2c_r(sd, 0x0a); | 2542 | high = i2c_r(sd, 0x0a); |
2581 | if (high < 0) { | 2543 | if (high < 0) { |
2582 | PDEBUG(D_ERR, "Error detecting camera chip PID"); | 2544 | PDEBUG(D_ERR, "Error detecting camera chip PID"); |
2583 | return high; | 2545 | return; |
2584 | } | 2546 | } |
2585 | low = i2c_r(sd, 0x0b); | 2547 | low = i2c_r(sd, 0x0b); |
2586 | if (low < 0) { | 2548 | if (low < 0) { |
2587 | PDEBUG(D_ERR, "Error detecting camera chip VER"); | 2549 | PDEBUG(D_ERR, "Error detecting camera chip VER"); |
2588 | return low; | 2550 | return; |
2589 | } | 2551 | } |
2590 | if (high == 0x76) { | 2552 | if (high == 0x76) { |
2591 | switch (low) { | 2553 | switch (low) { |
2592 | case 0x30: | 2554 | case 0x30: |
2593 | err("Sensor is an OV7630/OV7635"); | 2555 | err("Sensor is an OV7630/OV7635"); |
2594 | err("7630 is not supported by this driver"); | 2556 | err("7630 is not supported by this driver"); |
2595 | return -1; | 2557 | return; |
2596 | case 0x40: | 2558 | case 0x40: |
2597 | PDEBUG(D_PROBE, "Sensor is an OV7645"); | 2559 | PDEBUG(D_PROBE, "Sensor is an OV7645"); |
2598 | sd->sensor = SEN_OV7640; /* FIXME */ | 2560 | sd->sensor = SEN_OV7640; /* FIXME */ |
@@ -2607,7 +2569,7 @@ static int ov7xx0_configure(struct sd *sd) | |||
2607 | break; | 2569 | break; |
2608 | default: | 2570 | default: |
2609 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); | 2571 | PDEBUG(D_PROBE, "Unknown sensor: 0x76%x", low); |
2610 | return -1; | 2572 | return; |
2611 | } | 2573 | } |
2612 | } else { | 2574 | } else { |
2613 | PDEBUG(D_PROBE, "Sensor is an OV7620"); | 2575 | PDEBUG(D_PROBE, "Sensor is an OV7620"); |
@@ -2615,15 +2577,11 @@ static int ov7xx0_configure(struct sd *sd) | |||
2615 | } | 2577 | } |
2616 | } else { | 2578 | } else { |
2617 | err("Unknown image sensor version: %d", rc & 3); | 2579 | err("Unknown image sensor version: %d", rc & 3); |
2618 | return -1; | ||
2619 | } | 2580 | } |
2620 | |||
2621 | /* Set sensor-specific vars */ | ||
2622 | return 0; | ||
2623 | } | 2581 | } |
2624 | 2582 | ||
2625 | /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */ | 2583 | /* This initializes the OV6620, OV6630, OV6630AE, or OV6630AF sensor. */ |
2626 | static int ov6xx0_configure(struct sd *sd) | 2584 | static void ov6xx0_configure(struct sd *sd) |
2627 | { | 2585 | { |
2628 | int rc; | 2586 | int rc; |
2629 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); | 2587 | PDEBUG(D_PROBE, "starting OV6xx0 configuration"); |
@@ -2632,7 +2590,7 @@ static int ov6xx0_configure(struct sd *sd) | |||
2632 | rc = i2c_r(sd, OV7610_REG_COM_I); | 2590 | rc = i2c_r(sd, OV7610_REG_COM_I); |
2633 | if (rc < 0) { | 2591 | if (rc < 0) { |
2634 | PDEBUG(D_ERR, "Error detecting sensor type"); | 2592 | PDEBUG(D_ERR, "Error detecting sensor type"); |
2635 | return -1; | 2593 | return; |
2636 | } | 2594 | } |
2637 | 2595 | ||
2638 | /* Ugh. The first two bits are the version bits, but | 2596 | /* Ugh. The first two bits are the version bits, but |
@@ -2663,13 +2621,11 @@ static int ov6xx0_configure(struct sd *sd) | |||
2663 | break; | 2621 | break; |
2664 | default: | 2622 | default: |
2665 | err("FATAL: Unknown sensor version: 0x%02x", rc); | 2623 | err("FATAL: Unknown sensor version: 0x%02x", rc); |
2666 | return -1; | 2624 | return; |
2667 | } | 2625 | } |
2668 | 2626 | ||
2669 | /* Set sensor-specific vars */ | 2627 | /* Set sensor-specific vars */ |
2670 | sd->sif = 1; | 2628 | sd->sif = 1; |
2671 | |||
2672 | return 0; | ||
2673 | } | 2629 | } |
2674 | 2630 | ||
2675 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ | 2631 | /* Turns on or off the LED. Only has an effect with OV511+/OV518(+)/OV519 */ |
@@ -2723,7 +2679,7 @@ static void sd_reset_snapshot(struct gspca_dev *gspca_dev) | |||
2723 | } | 2679 | } |
2724 | } | 2680 | } |
2725 | 2681 | ||
2726 | static int ov51x_upload_quan_tables(struct sd *sd) | 2682 | static void ov51x_upload_quan_tables(struct sd *sd) |
2727 | { | 2683 | { |
2728 | const unsigned char yQuanTable511[] = { | 2684 | const unsigned char yQuanTable511[] = { |
2729 | 0, 1, 1, 2, 2, 3, 3, 4, | 2685 | 0, 1, 1, 2, 2, 3, 3, 4, |
@@ -2763,7 +2719,7 @@ static int ov51x_upload_quan_tables(struct sd *sd) | |||
2763 | 2719 | ||
2764 | const unsigned char *pYTable, *pUVTable; | 2720 | const unsigned char *pYTable, *pUVTable; |
2765 | unsigned char val0, val1; | 2721 | unsigned char val0, val1; |
2766 | int i, size, rc, reg = R51x_COMP_LUT_BEGIN; | 2722 | int i, size, reg = R51x_COMP_LUT_BEGIN; |
2767 | 2723 | ||
2768 | PDEBUG(D_PROBE, "Uploading quantization tables"); | 2724 | PDEBUG(D_PROBE, "Uploading quantization tables"); |
2769 | 2725 | ||
@@ -2783,30 +2739,23 @@ static int ov51x_upload_quan_tables(struct sd *sd) | |||
2783 | val0 &= 0x0f; | 2739 | val0 &= 0x0f; |
2784 | val1 &= 0x0f; | 2740 | val1 &= 0x0f; |
2785 | val0 |= val1 << 4; | 2741 | val0 |= val1 << 4; |
2786 | rc = reg_w(sd, reg, val0); | 2742 | reg_w(sd, reg, val0); |
2787 | if (rc < 0) | ||
2788 | return rc; | ||
2789 | 2743 | ||
2790 | val0 = *pUVTable++; | 2744 | val0 = *pUVTable++; |
2791 | val1 = *pUVTable++; | 2745 | val1 = *pUVTable++; |
2792 | val0 &= 0x0f; | 2746 | val0 &= 0x0f; |
2793 | val1 &= 0x0f; | 2747 | val1 &= 0x0f; |
2794 | val0 |= val1 << 4; | 2748 | val0 |= val1 << 4; |
2795 | rc = reg_w(sd, reg + size, val0); | 2749 | reg_w(sd, reg + size, val0); |
2796 | if (rc < 0) | ||
2797 | return rc; | ||
2798 | 2750 | ||
2799 | reg++; | 2751 | reg++; |
2800 | } | 2752 | } |
2801 | |||
2802 | return 0; | ||
2803 | } | 2753 | } |
2804 | 2754 | ||
2805 | /* This initializes the OV511/OV511+ and the sensor */ | 2755 | /* This initializes the OV511/OV511+ and the sensor */ |
2806 | static int ov511_configure(struct gspca_dev *gspca_dev) | 2756 | static void ov511_configure(struct gspca_dev *gspca_dev) |
2807 | { | 2757 | { |
2808 | struct sd *sd = (struct sd *) gspca_dev; | 2758 | struct sd *sd = (struct sd *) gspca_dev; |
2809 | int rc; | ||
2810 | 2759 | ||
2811 | /* For 511 and 511+ */ | 2760 | /* For 511 and 511+ */ |
2812 | const struct ov_regvals init_511[] = { | 2761 | const struct ov_regvals init_511[] = { |
@@ -2852,42 +2801,27 @@ static int ov511_configure(struct gspca_dev *gspca_dev) | |||
2852 | 2801 | ||
2853 | PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); | 2802 | PDEBUG(D_PROBE, "Device custom id %x", reg_r(sd, R51x_SYS_CUST_ID)); |
2854 | 2803 | ||
2855 | rc = write_regvals(sd, init_511, ARRAY_SIZE(init_511)); | 2804 | write_regvals(sd, init_511, ARRAY_SIZE(init_511)); |
2856 | if (rc < 0) | ||
2857 | return rc; | ||
2858 | 2805 | ||
2859 | switch (sd->bridge) { | 2806 | switch (sd->bridge) { |
2860 | case BRIDGE_OV511: | 2807 | case BRIDGE_OV511: |
2861 | rc = write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); | 2808 | write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); |
2862 | if (rc < 0) | ||
2863 | return rc; | ||
2864 | break; | 2809 | break; |
2865 | case BRIDGE_OV511PLUS: | 2810 | case BRIDGE_OV511PLUS: |
2866 | rc = write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); | 2811 | write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); |
2867 | if (rc < 0) | ||
2868 | return rc; | ||
2869 | break; | 2812 | break; |
2870 | } | 2813 | } |
2871 | 2814 | ||
2872 | /* Init compression */ | 2815 | /* Init compression */ |
2873 | rc = write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); | 2816 | write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); |
2874 | if (rc < 0) | ||
2875 | return rc; | ||
2876 | |||
2877 | rc = ov51x_upload_quan_tables(sd); | ||
2878 | if (rc < 0) { | ||
2879 | PDEBUG(D_ERR, "Error uploading quantization tables"); | ||
2880 | return rc; | ||
2881 | } | ||
2882 | 2817 | ||
2883 | return 0; | 2818 | ov51x_upload_quan_tables(sd); |
2884 | } | 2819 | } |
2885 | 2820 | ||
2886 | /* This initializes the OV518/OV518+ and the sensor */ | 2821 | /* This initializes the OV518/OV518+ and the sensor */ |
2887 | static int ov518_configure(struct gspca_dev *gspca_dev) | 2822 | static void ov518_configure(struct gspca_dev *gspca_dev) |
2888 | { | 2823 | { |
2889 | struct sd *sd = (struct sd *) gspca_dev; | 2824 | struct sd *sd = (struct sd *) gspca_dev; |
2890 | int rc; | ||
2891 | 2825 | ||
2892 | /* For 518 and 518+ */ | 2826 | /* For 518 and 518+ */ |
2893 | const struct ov_regvals init_518[] = { | 2827 | const struct ov_regvals init_518[] = { |
@@ -2937,42 +2871,26 @@ static int ov518_configure(struct gspca_dev *gspca_dev) | |||
2937 | PDEBUG(D_PROBE, "Device revision %d", | 2871 | PDEBUG(D_PROBE, "Device revision %d", |
2938 | 0x1f & reg_r(sd, R51x_SYS_CUST_ID)); | 2872 | 0x1f & reg_r(sd, R51x_SYS_CUST_ID)); |
2939 | 2873 | ||
2940 | rc = write_regvals(sd, init_518, ARRAY_SIZE(init_518)); | 2874 | write_regvals(sd, init_518, ARRAY_SIZE(init_518)); |
2941 | if (rc < 0) | ||
2942 | return rc; | ||
2943 | 2875 | ||
2944 | /* Set LED GPIO pin to output mode */ | 2876 | /* Set LED GPIO pin to output mode */ |
2945 | rc = reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02); | 2877 | reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02); |
2946 | if (rc < 0) | ||
2947 | return rc; | ||
2948 | 2878 | ||
2949 | switch (sd->bridge) { | 2879 | switch (sd->bridge) { |
2950 | case BRIDGE_OV518: | 2880 | case BRIDGE_OV518: |
2951 | rc = write_regvals(sd, norm_518, ARRAY_SIZE(norm_518)); | 2881 | write_regvals(sd, norm_518, ARRAY_SIZE(norm_518)); |
2952 | if (rc < 0) | ||
2953 | return rc; | ||
2954 | break; | 2882 | break; |
2955 | case BRIDGE_OV518PLUS: | 2883 | case BRIDGE_OV518PLUS: |
2956 | rc = write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p)); | 2884 | write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p)); |
2957 | if (rc < 0) | ||
2958 | return rc; | ||
2959 | break; | 2885 | break; |
2960 | } | 2886 | } |
2961 | 2887 | ||
2962 | rc = ov51x_upload_quan_tables(sd); | 2888 | ov51x_upload_quan_tables(sd); |
2963 | if (rc < 0) { | ||
2964 | PDEBUG(D_ERR, "Error uploading quantization tables"); | ||
2965 | return rc; | ||
2966 | } | ||
2967 | |||
2968 | rc = reg_w(sd, 0x2f, 0x80); | ||
2969 | if (rc < 0) | ||
2970 | return rc; | ||
2971 | 2889 | ||
2972 | return 0; | 2890 | reg_w(sd, 0x2f, 0x80); |
2973 | } | 2891 | } |
2974 | 2892 | ||
2975 | static int ov519_configure(struct sd *sd) | 2893 | static void ov519_configure(struct sd *sd) |
2976 | { | 2894 | { |
2977 | static const struct ov_regvals init_519[] = { | 2895 | static const struct ov_regvals init_519[] = { |
2978 | { 0x5a, 0x6d }, /* EnableSystem */ | 2896 | { 0x5a, 0x6d }, /* EnableSystem */ |
@@ -2990,10 +2908,10 @@ static int ov519_configure(struct sd *sd) | |||
2990 | /* windows reads 0x55 at this point*/ | 2908 | /* windows reads 0x55 at this point*/ |
2991 | }; | 2909 | }; |
2992 | 2910 | ||
2993 | return write_regvals(sd, init_519, ARRAY_SIZE(init_519)); | 2911 | write_regvals(sd, init_519, ARRAY_SIZE(init_519)); |
2994 | } | 2912 | } |
2995 | 2913 | ||
2996 | static int ovfx2_configure(struct sd *sd) | 2914 | static void ovfx2_configure(struct sd *sd) |
2997 | { | 2915 | { |
2998 | static const struct ov_regvals init_fx2[] = { | 2916 | static const struct ov_regvals init_fx2[] = { |
2999 | { 0x00, 0x60 }, | 2917 | { 0x00, 0x60 }, |
@@ -3007,7 +2925,7 @@ static int ovfx2_configure(struct sd *sd) | |||
3007 | 2925 | ||
3008 | sd->stopped = 1; | 2926 | sd->stopped = 1; |
3009 | 2927 | ||
3010 | return write_regvals(sd, init_fx2, ARRAY_SIZE(init_fx2)); | 2928 | write_regvals(sd, init_fx2, ARRAY_SIZE(init_fx2)); |
3011 | } | 2929 | } |
3012 | 2930 | ||
3013 | /* this function is called at probe time */ | 2931 | /* this function is called at probe time */ |
@@ -3016,7 +2934,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3016 | { | 2934 | { |
3017 | struct sd *sd = (struct sd *) gspca_dev; | 2935 | struct sd *sd = (struct sd *) gspca_dev; |
3018 | struct cam *cam = &gspca_dev->cam; | 2936 | struct cam *cam = &gspca_dev->cam; |
3019 | int ret = 0; | ||
3020 | 2937 | ||
3021 | sd->bridge = id->driver_info & BRIDGE_MASK; | 2938 | sd->bridge = id->driver_info & BRIDGE_MASK; |
3022 | sd->invert_led = id->driver_info & BRIDGE_INVERT_LED; | 2939 | sd->invert_led = id->driver_info & BRIDGE_INVERT_LED; |
@@ -3024,30 +2941,27 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3024 | switch (sd->bridge) { | 2941 | switch (sd->bridge) { |
3025 | case BRIDGE_OV511: | 2942 | case BRIDGE_OV511: |
3026 | case BRIDGE_OV511PLUS: | 2943 | case BRIDGE_OV511PLUS: |
3027 | ret = ov511_configure(gspca_dev); | 2944 | ov511_configure(gspca_dev); |
3028 | break; | 2945 | break; |
3029 | case BRIDGE_OV518: | 2946 | case BRIDGE_OV518: |
3030 | case BRIDGE_OV518PLUS: | 2947 | case BRIDGE_OV518PLUS: |
3031 | ret = ov518_configure(gspca_dev); | 2948 | ov518_configure(gspca_dev); |
3032 | break; | 2949 | break; |
3033 | case BRIDGE_OV519: | 2950 | case BRIDGE_OV519: |
3034 | ret = ov519_configure(sd); | 2951 | ov519_configure(sd); |
3035 | break; | 2952 | break; |
3036 | case BRIDGE_OVFX2: | 2953 | case BRIDGE_OVFX2: |
3037 | ret = ovfx2_configure(sd); | 2954 | ovfx2_configure(sd); |
3038 | cam->bulk_size = OVFX2_BULK_SIZE; | 2955 | cam->bulk_size = OVFX2_BULK_SIZE; |
3039 | cam->bulk_nurbs = MAX_NURBS; | 2956 | cam->bulk_nurbs = MAX_NURBS; |
3040 | cam->bulk = 1; | 2957 | cam->bulk = 1; |
3041 | break; | 2958 | break; |
3042 | case BRIDGE_W9968CF: | 2959 | case BRIDGE_W9968CF: |
3043 | ret = w9968cf_configure(sd); | 2960 | w9968cf_configure(sd); |
3044 | cam->reverse_alts = 1; | 2961 | cam->reverse_alts = 1; |
3045 | break; | 2962 | break; |
3046 | } | 2963 | } |
3047 | 2964 | ||
3048 | if (ret) | ||
3049 | goto error; | ||
3050 | |||
3051 | ov51x_led_control(sd, 0); /* turn LED off */ | 2965 | ov51x_led_control(sd, 0); /* turn LED off */ |
3052 | 2966 | ||
3053 | /* The OV519 must be more aggressive about sensor detection since | 2967 | /* The OV519 must be more aggressive about sensor detection since |
@@ -3057,28 +2971,19 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3057 | 2971 | ||
3058 | /* Test for 76xx */ | 2972 | /* Test for 76xx */ |
3059 | if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { | 2973 | if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { |
3060 | if (ov7xx0_configure(sd) < 0) { | 2974 | ov7xx0_configure(sd); |
3061 | PDEBUG(D_ERR, "Failed to configure OV7xx0"); | 2975 | |
3062 | goto error; | ||
3063 | } | ||
3064 | /* Test for 6xx0 */ | 2976 | /* Test for 6xx0 */ |
3065 | } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { | 2977 | } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { |
3066 | if (ov6xx0_configure(sd) < 0) { | 2978 | ov6xx0_configure(sd); |
3067 | PDEBUG(D_ERR, "Failed to configure OV6xx0"); | 2979 | |
3068 | goto error; | ||
3069 | } | ||
3070 | /* Test for 8xx0 */ | 2980 | /* Test for 8xx0 */ |
3071 | } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { | 2981 | } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { |
3072 | if (ov8xx0_configure(sd) < 0) { | 2982 | ov8xx0_configure(sd); |
3073 | PDEBUG(D_ERR, "Failed to configure OV8xx0"); | 2983 | |
3074 | goto error; | ||
3075 | } | ||
3076 | /* Test for 3xxx / 2xxx */ | 2984 | /* Test for 3xxx / 2xxx */ |
3077 | } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { | 2985 | } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { |
3078 | if (ov_hires_configure(sd) < 0) { | 2986 | ov_hires_configure(sd); |
3079 | PDEBUG(D_ERR, "Failed to configure high res OV"); | ||
3080 | goto error; | ||
3081 | } | ||
3082 | } else { | 2987 | } else { |
3083 | err("Can't determine sensor slave IDs"); | 2988 | err("Can't determine sensor slave IDs"); |
3084 | goto error; | 2989 | goto error; |
@@ -3139,8 +3044,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3139 | cam->nmodes--; | 3044 | cam->nmodes--; |
3140 | 3045 | ||
3141 | /* w9968cf needs initialisation once the sensor is known */ | 3046 | /* w9968cf needs initialisation once the sensor is known */ |
3142 | if (w9968cf_init(sd) < 0) | 3047 | w9968cf_init(sd); |
3143 | goto error; | ||
3144 | break; | 3048 | break; |
3145 | } | 3049 | } |
3146 | gspca_dev->cam.ctrls = sd->ctrls; | 3050 | gspca_dev->cam.ctrls = sd->ctrls; |
@@ -3148,7 +3052,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
3148 | 3052 | ||
3149 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; | 3053 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
3150 | 3054 | ||
3151 | return 0; | 3055 | return gspca_dev->usb_err; |
3152 | error: | 3056 | error: |
3153 | PDEBUG(D_ERR, "OV519 Config failed"); | 3057 | PDEBUG(D_ERR, "OV519 Config failed"); |
3154 | return -EINVAL; | 3058 | return -EINVAL; |
@@ -3162,67 +3066,57 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
3162 | /* initialize the sensor */ | 3066 | /* initialize the sensor */ |
3163 | switch (sd->sensor) { | 3067 | switch (sd->sensor) { |
3164 | case SEN_OV2610: | 3068 | case SEN_OV2610: |
3165 | if (write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610))) | 3069 | write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610)); |
3166 | return -EIO; | 3070 | |
3167 | /* Enable autogain, autoexpo, awb, bandfilter */ | 3071 | /* Enable autogain, autoexpo, awb, bandfilter */ |
3168 | if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0) | 3072 | i2c_w_mask(sd, 0x13, 0x27, 0x27); |
3169 | return -EIO; | ||
3170 | break; | 3073 | break; |
3171 | case SEN_OV3610: | 3074 | case SEN_OV3610: |
3172 | if (write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b))) | 3075 | write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b)); |
3173 | return -EIO; | 3076 | |
3174 | /* Enable autogain, autoexpo, awb, bandfilter */ | 3077 | /* Enable autogain, autoexpo, awb, bandfilter */ |
3175 | if (i2c_w_mask(sd, 0x13, 0x27, 0x27) < 0) | 3078 | i2c_w_mask(sd, 0x13, 0x27, 0x27); |
3176 | return -EIO; | ||
3177 | break; | 3079 | break; |
3178 | case SEN_OV6620: | 3080 | case SEN_OV6620: |
3179 | if (write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20))) | 3081 | write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20)); |
3180 | return -EIO; | ||
3181 | break; | 3082 | break; |
3182 | case SEN_OV6630: | 3083 | case SEN_OV6630: |
3183 | case SEN_OV66308AF: | 3084 | case SEN_OV66308AF: |
3184 | sd->ctrls[CONTRAST].def = 200; | 3085 | sd->ctrls[CONTRAST].def = 200; |
3185 | /* The default is too low for the ov6630 */ | 3086 | /* The default is too low for the ov6630 */ |
3186 | if (write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30))) | 3087 | write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30)); |
3187 | return -EIO; | ||
3188 | break; | 3088 | break; |
3189 | default: | 3089 | default: |
3190 | /* case SEN_OV7610: */ | 3090 | /* case SEN_OV7610: */ |
3191 | /* case SEN_OV76BE: */ | 3091 | /* case SEN_OV76BE: */ |
3192 | if (write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610))) | 3092 | write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610)); |
3193 | return -EIO; | 3093 | i2c_w_mask(sd, 0x0e, 0x00, 0x40); |
3194 | if (i2c_w_mask(sd, 0x0e, 0x00, 0x40)) | ||
3195 | return -EIO; | ||
3196 | break; | 3094 | break; |
3197 | case SEN_OV7620: | 3095 | case SEN_OV7620: |
3198 | case SEN_OV7620AE: | 3096 | case SEN_OV7620AE: |
3199 | if (write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620))) | 3097 | write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620)); |
3200 | return -EIO; | ||
3201 | break; | 3098 | break; |
3202 | case SEN_OV7640: | 3099 | case SEN_OV7640: |
3203 | case SEN_OV7648: | 3100 | case SEN_OV7648: |
3204 | if (write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640))) | 3101 | write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640)); |
3205 | return -EIO; | ||
3206 | break; | 3102 | break; |
3207 | case SEN_OV7670: | 3103 | case SEN_OV7670: |
3208 | sd->ctrls[FREQ].max = 3; /* auto */ | 3104 | sd->ctrls[FREQ].max = 3; /* auto */ |
3209 | sd->ctrls[FREQ].def = 3; | 3105 | sd->ctrls[FREQ].def = 3; |
3210 | if (write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670))) | 3106 | write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670)); |
3211 | return -EIO; | ||
3212 | break; | 3107 | break; |
3213 | case SEN_OV8610: | 3108 | case SEN_OV8610: |
3214 | if (write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610))) | 3109 | write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610)); |
3215 | return -EIO; | ||
3216 | break; | 3110 | break; |
3217 | } | 3111 | } |
3218 | return 0; | 3112 | return gspca_dev->usb_err; |
3219 | } | 3113 | } |
3220 | 3114 | ||
3221 | /* Set up the OV511/OV511+ with the given image parameters. | 3115 | /* Set up the OV511/OV511+ with the given image parameters. |
3222 | * | 3116 | * |
3223 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3117 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3224 | */ | 3118 | */ |
3225 | static int ov511_mode_init_regs(struct sd *sd) | 3119 | static void ov511_mode_init_regs(struct sd *sd) |
3226 | { | 3120 | { |
3227 | int hsegs, vsegs, packet_size, fps, needed; | 3121 | int hsegs, vsegs, packet_size, fps, needed; |
3228 | int interlaced = 0; | 3122 | int interlaced = 0; |
@@ -3233,7 +3127,8 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3233 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | 3127 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); |
3234 | if (!alt) { | 3128 | if (!alt) { |
3235 | err("Couldn't get altsetting"); | 3129 | err("Couldn't get altsetting"); |
3236 | return -EIO; | 3130 | sd->gspca_dev.usb_err = -EIO; |
3131 | return; | ||
3237 | } | 3132 | } |
3238 | 3133 | ||
3239 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 3134 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); |
@@ -3336,8 +3231,6 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3336 | 3231 | ||
3337 | reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); | 3232 | reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); |
3338 | reg_w(sd, R51x_SYS_RESET, 0); | 3233 | reg_w(sd, R51x_SYS_RESET, 0); |
3339 | |||
3340 | return 0; | ||
3341 | } | 3234 | } |
3342 | 3235 | ||
3343 | /* Sets up the OV518/OV518+ with the given image parameters | 3236 | /* Sets up the OV518/OV518+ with the given image parameters |
@@ -3347,7 +3240,7 @@ static int ov511_mode_init_regs(struct sd *sd) | |||
3347 | * | 3240 | * |
3348 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3241 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3349 | */ | 3242 | */ |
3350 | static int ov518_mode_init_regs(struct sd *sd) | 3243 | static void ov518_mode_init_regs(struct sd *sd) |
3351 | { | 3244 | { |
3352 | int hsegs, vsegs, packet_size; | 3245 | int hsegs, vsegs, packet_size; |
3353 | struct usb_host_interface *alt; | 3246 | struct usb_host_interface *alt; |
@@ -3357,7 +3250,8 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3357 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); | 3250 | alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); |
3358 | if (!alt) { | 3251 | if (!alt) { |
3359 | err("Couldn't get altsetting"); | 3252 | err("Couldn't get altsetting"); |
3360 | return -EIO; | 3253 | sd->gspca_dev.usb_err = -EIO; |
3254 | return; | ||
3361 | } | 3255 | } |
3362 | 3256 | ||
3363 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); | 3257 | packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); |
@@ -3460,8 +3354,6 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3460 | } | 3354 | } |
3461 | 3355 | ||
3462 | reg_w(sd, 0x2f, 0x80); | 3356 | reg_w(sd, 0x2f, 0x80); |
3463 | |||
3464 | return 0; | ||
3465 | } | 3357 | } |
3466 | 3358 | ||
3467 | /* Sets up the OV519 with the given image parameters | 3359 | /* Sets up the OV519 with the given image parameters |
@@ -3471,7 +3363,7 @@ static int ov518_mode_init_regs(struct sd *sd) | |||
3471 | * | 3363 | * |
3472 | * Do not put any sensor-specific code in here (including I2C I/O functions) | 3364 | * Do not put any sensor-specific code in here (including I2C I/O functions) |
3473 | */ | 3365 | */ |
3474 | static int ov519_mode_init_regs(struct sd *sd) | 3366 | static void ov519_mode_init_regs(struct sd *sd) |
3475 | { | 3367 | { |
3476 | static const struct ov_regvals mode_init_519_ov7670[] = { | 3368 | static const struct ov_regvals mode_init_519_ov7670[] = { |
3477 | { 0x5d, 0x03 }, /* Turn off suspend mode */ | 3369 | { 0x5d, 0x03 }, /* Turn off suspend mode */ |
@@ -3519,18 +3411,15 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
3519 | 3411 | ||
3520 | /******** Set the mode ********/ | 3412 | /******** Set the mode ********/ |
3521 | if (sd->sensor != SEN_OV7670) { | 3413 | if (sd->sensor != SEN_OV7670) { |
3522 | if (write_regvals(sd, mode_init_519, | 3414 | write_regvals(sd, mode_init_519, ARRAY_SIZE(mode_init_519)); |
3523 | ARRAY_SIZE(mode_init_519))) | ||
3524 | return -EIO; | ||
3525 | if (sd->sensor == SEN_OV7640 || | 3415 | if (sd->sensor == SEN_OV7640 || |
3526 | sd->sensor == SEN_OV7648) { | 3416 | sd->sensor == SEN_OV7648) { |
3527 | /* Select 8-bit input mode */ | 3417 | /* Select 8-bit input mode */ |
3528 | reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10); | 3418 | reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10); |
3529 | } | 3419 | } |
3530 | } else { | 3420 | } else { |
3531 | if (write_regvals(sd, mode_init_519_ov7670, | 3421 | write_regvals(sd, mode_init_519_ov7670, |
3532 | ARRAY_SIZE(mode_init_519_ov7670))) | 3422 | ARRAY_SIZE(mode_init_519_ov7670)); |
3533 | return -EIO; | ||
3534 | } | 3423 | } |
3535 | 3424 | ||
3536 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); | 3425 | reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.width >> 4); |
@@ -3626,10 +3515,9 @@ static int ov519_mode_init_regs(struct sd *sd) | |||
3626 | } | 3515 | } |
3627 | break; | 3516 | break; |
3628 | } | 3517 | } |
3629 | return 0; | ||
3630 | } | 3518 | } |
3631 | 3519 | ||
3632 | static int mode_init_ov_sensor_regs(struct sd *sd) | 3520 | static void mode_init_ov_sensor_regs(struct sd *sd) |
3633 | { | 3521 | { |
3634 | struct gspca_dev *gspca_dev; | 3522 | struct gspca_dev *gspca_dev; |
3635 | int qvga, xstart, xend, ystart, yend; | 3523 | int qvga, xstart, xend, ystart, yend; |
@@ -3648,7 +3536,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3648 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); | 3536 | i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); |
3649 | i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); | 3537 | i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); |
3650 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); | 3538 | i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); |
3651 | return 0; | 3539 | return; |
3652 | case SEN_OV3610: | 3540 | case SEN_OV3610: |
3653 | if (qvga) { | 3541 | if (qvga) { |
3654 | xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4); | 3542 | xstart = (1040 - gspca_dev->width) / 2 + (0x1f << 4); |
@@ -3672,7 +3560,7 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3672 | i2c_w(sd, 0x18, xend >> 4); | 3560 | i2c_w(sd, 0x18, xend >> 4); |
3673 | i2c_w(sd, 0x19, ystart >> 3); | 3561 | i2c_w(sd, 0x19, ystart >> 3); |
3674 | i2c_w(sd, 0x1a, yend >> 3); | 3562 | i2c_w(sd, 0x1a, yend >> 3); |
3675 | return 0; | 3563 | return; |
3676 | case SEN_OV8610: | 3564 | case SEN_OV8610: |
3677 | /* For OV8610 qvga means qsvga */ | 3565 | /* For OV8610 qvga means qsvga */ |
3678 | i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); | 3566 | i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); |
@@ -3766,13 +3654,11 @@ static int mode_init_ov_sensor_regs(struct sd *sd) | |||
3766 | i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ | 3654 | i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ |
3767 | break; | 3655 | break; |
3768 | default: | 3656 | default: |
3769 | return -EINVAL; | 3657 | return; |
3770 | } | 3658 | } |
3771 | 3659 | ||
3772 | /******** Clock programming ********/ | 3660 | /******** Clock programming ********/ |
3773 | i2c_w(sd, 0x11, sd->clockdiv); | 3661 | i2c_w(sd, 0x11, sd->clockdiv); |
3774 | |||
3775 | return 0; | ||
3776 | } | 3662 | } |
3777 | 3663 | ||
3778 | static void sethvflip(struct gspca_dev *gspca_dev) | 3664 | static void sethvflip(struct gspca_dev *gspca_dev) |
@@ -3791,18 +3677,18 @@ static void sethvflip(struct gspca_dev *gspca_dev) | |||
3791 | ov51x_restart(sd); | 3677 | ov51x_restart(sd); |
3792 | } | 3678 | } |
3793 | 3679 | ||
3794 | static int set_ov_sensor_window(struct sd *sd) | 3680 | static void set_ov_sensor_window(struct sd *sd) |
3795 | { | 3681 | { |
3796 | struct gspca_dev *gspca_dev; | 3682 | struct gspca_dev *gspca_dev; |
3797 | int qvga, crop; | 3683 | int qvga, crop; |
3798 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; | 3684 | int hwsbase, hwebase, vwsbase, vwebase, hwscale, vwscale; |
3799 | int ret; | ||
3800 | 3685 | ||
3801 | /* mode setup is fully handled in mode_init_ov_sensor_regs for these */ | 3686 | /* mode setup is fully handled in mode_init_ov_sensor_regs for these */ |
3802 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610 || | 3687 | if (sd->sensor == SEN_OV2610 || sd->sensor == SEN_OV3610 || |
3803 | sd->sensor == SEN_OV7670) | 3688 | sd->sensor == SEN_OV7670) { |
3804 | return mode_init_ov_sensor_regs(sd); | 3689 | mode_init_ov_sensor_regs(sd); |
3805 | 3690 | return; | |
3691 | } | ||
3806 | gspca_dev = &sd->gspca_dev; | 3692 | gspca_dev = &sd->gspca_dev; |
3807 | qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; | 3693 | qvga = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 1; |
3808 | crop = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 2; | 3694 | crop = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & 2; |
@@ -3852,7 +3738,7 @@ static int set_ov_sensor_window(struct sd *sd) | |||
3852 | vwsbase = vwebase = 0x03; | 3738 | vwsbase = vwebase = 0x03; |
3853 | break; | 3739 | break; |
3854 | default: | 3740 | default: |
3855 | return -EINVAL; | 3741 | return; |
3856 | } | 3742 | } |
3857 | 3743 | ||
3858 | switch (sd->sensor) { | 3744 | switch (sd->sensor) { |
@@ -3887,23 +3773,18 @@ static int set_ov_sensor_window(struct sd *sd) | |||
3887 | } | 3773 | } |
3888 | } | 3774 | } |
3889 | 3775 | ||
3890 | ret = mode_init_ov_sensor_regs(sd); | 3776 | mode_init_ov_sensor_regs(sd); |
3891 | if (ret < 0) | ||
3892 | return ret; | ||
3893 | 3777 | ||
3894 | i2c_w(sd, 0x17, hwsbase); | 3778 | i2c_w(sd, 0x17, hwsbase); |
3895 | i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); | 3779 | i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); |
3896 | i2c_w(sd, 0x19, vwsbase); | 3780 | i2c_w(sd, 0x19, vwsbase); |
3897 | i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); | 3781 | i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); |
3898 | |||
3899 | return 0; | ||
3900 | } | 3782 | } |
3901 | 3783 | ||
3902 | /* -- start the camera -- */ | 3784 | /* -- start the camera -- */ |
3903 | static int sd_start(struct gspca_dev *gspca_dev) | 3785 | static int sd_start(struct gspca_dev *gspca_dev) |
3904 | { | 3786 | { |
3905 | struct sd *sd = (struct sd *) gspca_dev; | 3787 | struct sd *sd = (struct sd *) gspca_dev; |
3906 | int ret = 0; | ||
3907 | 3788 | ||
3908 | /* Default for most bridges, allow bridge_mode_init_regs to override */ | 3789 | /* Default for most bridges, allow bridge_mode_init_regs to override */ |
3909 | sd->sensor_width = sd->gspca_dev.width; | 3790 | sd->sensor_width = sd->gspca_dev.width; |
@@ -3912,26 +3793,22 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
3912 | switch (sd->bridge) { | 3793 | switch (sd->bridge) { |
3913 | case BRIDGE_OV511: | 3794 | case BRIDGE_OV511: |
3914 | case BRIDGE_OV511PLUS: | 3795 | case BRIDGE_OV511PLUS: |
3915 | ret = ov511_mode_init_regs(sd); | 3796 | ov511_mode_init_regs(sd); |
3916 | break; | 3797 | break; |
3917 | case BRIDGE_OV518: | 3798 | case BRIDGE_OV518: |
3918 | case BRIDGE_OV518PLUS: | 3799 | case BRIDGE_OV518PLUS: |
3919 | ret = ov518_mode_init_regs(sd); | 3800 | ov518_mode_init_regs(sd); |
3920 | break; | 3801 | break; |
3921 | case BRIDGE_OV519: | 3802 | case BRIDGE_OV519: |
3922 | ret = ov519_mode_init_regs(sd); | 3803 | ov519_mode_init_regs(sd); |
3923 | break; | 3804 | break; |
3924 | /* case BRIDGE_OVFX2: nothing to do */ | 3805 | /* case BRIDGE_OVFX2: nothing to do */ |
3925 | case BRIDGE_W9968CF: | 3806 | case BRIDGE_W9968CF: |
3926 | ret = w9968cf_mode_init_regs(sd); | 3807 | w9968cf_mode_init_regs(sd); |
3927 | break; | 3808 | break; |
3928 | } | 3809 | } |
3929 | if (ret < 0) | ||
3930 | goto out; | ||
3931 | 3810 | ||
3932 | ret = set_ov_sensor_window(sd); | 3811 | set_ov_sensor_window(sd); |
3933 | if (ret < 0) | ||
3934 | goto out; | ||
3935 | 3812 | ||
3936 | setcontrast(gspca_dev); | 3813 | setcontrast(gspca_dev); |
3937 | setbrightness(gspca_dev); | 3814 | setbrightness(gspca_dev); |
@@ -3947,14 +3824,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
3947 | 3824 | ||
3948 | sd->first_frame = 3; | 3825 | sd->first_frame = 3; |
3949 | 3826 | ||
3950 | ret = ov51x_restart(sd); | 3827 | ov51x_restart(sd); |
3951 | if (ret < 0) | ||
3952 | goto out; | ||
3953 | ov51x_led_control(sd, 1); | 3828 | ov51x_led_control(sd, 1); |
3954 | return 0; | 3829 | return gspca_dev->usb_err; |
3955 | out: | ||
3956 | PDEBUG(D_ERR, "camera start error:%d", ret); | ||
3957 | return ret; | ||
3958 | } | 3830 | } |
3959 | 3831 | ||
3960 | static void sd_stopN(struct gspca_dev *gspca_dev) | 3832 | static void sd_stopN(struct gspca_dev *gspca_dev) |
diff --git a/drivers/media/video/gspca/w996Xcf.c b/drivers/media/video/gspca/w996Xcf.c index 8bffde198a15..4a9e622e5e1b 100644 --- a/drivers/media/video/gspca/w996Xcf.c +++ b/drivers/media/video/gspca/w996Xcf.c | |||
@@ -59,18 +59,21 @@ static const struct v4l2_pix_format w9968cf_vga_mode[] = { | |||
59 | .colorspace = V4L2_COLORSPACE_JPEG}, | 59 | .colorspace = V4L2_COLORSPACE_JPEG}, |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static int reg_w(struct sd *sd, u16 index, u16 value); | 62 | static void reg_w(struct sd *sd, u16 index, u16 value); |
63 | 63 | ||
64 | /*-------------------------------------------------------------------------- | 64 | /*-------------------------------------------------------------------------- |
65 | Write 64-bit data to the fast serial bus registers. | 65 | Write 64-bit data to the fast serial bus registers. |
66 | Return 0 on success, -1 otherwise. | 66 | Return 0 on success, -1 otherwise. |
67 | --------------------------------------------------------------------------*/ | 67 | --------------------------------------------------------------------------*/ |
68 | static int w9968cf_write_fsb(struct sd *sd, u16* data) | 68 | static void w9968cf_write_fsb(struct sd *sd, u16* data) |
69 | { | 69 | { |
70 | struct usb_device *udev = sd->gspca_dev.dev; | 70 | struct usb_device *udev = sd->gspca_dev.dev; |
71 | u16 value; | 71 | u16 value; |
72 | int ret; | 72 | int ret; |
73 | 73 | ||
74 | if (sd->gspca_dev.usb_err < 0) | ||
75 | return; | ||
76 | |||
74 | value = *data++; | 77 | value = *data++; |
75 | memcpy(sd->gspca_dev.usb_buf, data, 6); | 78 | memcpy(sd->gspca_dev.usb_buf, data, 6); |
76 | 79 | ||
@@ -79,20 +82,21 @@ static int w9968cf_write_fsb(struct sd *sd, u16* data) | |||
79 | value, 0x06, sd->gspca_dev.usb_buf, 6, 500); | 82 | value, 0x06, sd->gspca_dev.usb_buf, 6, 500); |
80 | if (ret < 0) { | 83 | if (ret < 0) { |
81 | err("Write FSB registers failed (%d)", ret); | 84 | err("Write FSB registers failed (%d)", ret); |
82 | return ret; | 85 | sd->gspca_dev.usb_err = ret; |
83 | } | 86 | } |
84 | |||
85 | return 0; | ||
86 | } | 87 | } |
87 | 88 | ||
88 | /*-------------------------------------------------------------------------- | 89 | /*-------------------------------------------------------------------------- |
89 | Write data to the serial bus control register. | 90 | Write data to the serial bus control register. |
90 | Return 0 on success, a negative number otherwise. | 91 | Return 0 on success, a negative number otherwise. |
91 | --------------------------------------------------------------------------*/ | 92 | --------------------------------------------------------------------------*/ |
92 | static int w9968cf_write_sb(struct sd *sd, u16 value) | 93 | static void w9968cf_write_sb(struct sd *sd, u16 value) |
93 | { | 94 | { |
94 | int ret; | 95 | int ret; |
95 | 96 | ||
97 | if (sd->gspca_dev.usb_err < 0) | ||
98 | return; | ||
99 | |||
96 | /* We don't use reg_w here, as that would cause all writes when | 100 | /* We don't use reg_w here, as that would cause all writes when |
97 | bitbanging i2c to be logged, making the logs impossible to read */ | 101 | bitbanging i2c to be logged, making the logs impossible to read */ |
98 | ret = usb_control_msg(sd->gspca_dev.dev, | 102 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -105,10 +109,8 @@ static int w9968cf_write_sb(struct sd *sd, u16 value) | |||
105 | 109 | ||
106 | if (ret < 0) { | 110 | if (ret < 0) { |
107 | err("Write SB reg [01] %04x failed", value); | 111 | err("Write SB reg [01] %04x failed", value); |
108 | return ret; | 112 | sd->gspca_dev.usb_err = ret; |
109 | } | 113 | } |
110 | |||
111 | return 0; | ||
112 | } | 114 | } |
113 | 115 | ||
114 | /*-------------------------------------------------------------------------- | 116 | /*-------------------------------------------------------------------------- |
@@ -119,6 +121,9 @@ static int w9968cf_read_sb(struct sd *sd) | |||
119 | { | 121 | { |
120 | int ret; | 122 | int ret; |
121 | 123 | ||
124 | if (sd->gspca_dev.usb_err < 0) | ||
125 | return -1; | ||
126 | |||
122 | /* We don't use reg_r here, as the w9968cf is special and has 16 | 127 | /* We don't use reg_r here, as the w9968cf is special and has 16 |
123 | bit registers instead of 8 bit */ | 128 | bit registers instead of 8 bit */ |
124 | ret = usb_control_msg(sd->gspca_dev.dev, | 129 | ret = usb_control_msg(sd->gspca_dev.dev, |
@@ -126,11 +131,13 @@ static int w9968cf_read_sb(struct sd *sd) | |||
126 | 1, | 131 | 1, |
127 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 132 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
128 | 0, 0x01, sd->gspca_dev.usb_buf, 2, 500); | 133 | 0, 0x01, sd->gspca_dev.usb_buf, 2, 500); |
129 | if (ret >= 0) | 134 | if (ret >= 0) { |
130 | ret = sd->gspca_dev.usb_buf[0] | | 135 | ret = sd->gspca_dev.usb_buf[0] | |
131 | (sd->gspca_dev.usb_buf[1] << 8); | 136 | (sd->gspca_dev.usb_buf[1] << 8); |
132 | else | 137 | } else { |
133 | err("Read SB reg [01] failed"); | 138 | err("Read SB reg [01] failed"); |
139 | sd->gspca_dev.usb_err = ret; | ||
140 | } | ||
134 | 141 | ||
135 | udelay(W9968CF_I2C_BUS_DELAY); | 142 | udelay(W9968CF_I2C_BUS_DELAY); |
136 | 143 | ||
@@ -142,12 +149,12 @@ static int w9968cf_read_sb(struct sd *sd) | |||
142 | This function is called by w9968cf_start_transfer(). | 149 | This function is called by w9968cf_start_transfer(). |
143 | Return 0 on success, a negative number otherwise. | 150 | Return 0 on success, a negative number otherwise. |
144 | --------------------------------------------------------------------------*/ | 151 | --------------------------------------------------------------------------*/ |
145 | static int w9968cf_upload_quantizationtables(struct sd *sd) | 152 | static void w9968cf_upload_quantizationtables(struct sd *sd) |
146 | { | 153 | { |
147 | u16 a, b; | 154 | u16 a, b; |
148 | int ret = 0, i, j; | 155 | int i, j; |
149 | 156 | ||
150 | ret += reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */ | 157 | reg_w(sd, 0x39, 0x0010); /* JPEG clock enable */ |
151 | 158 | ||
152 | for (i = 0, j = 0; i < 32; i++, j += 2) { | 159 | for (i = 0, j = 0; i < 32; i++, j += 2) { |
153 | a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j + 1]) << 8); | 160 | a = Y_QUANTABLE[j] | ((unsigned)(Y_QUANTABLE[j + 1]) << 8); |
@@ -155,9 +162,7 @@ static int w9968cf_upload_quantizationtables(struct sd *sd) | |||
155 | reg_w(sd, 0x40 + i, a); | 162 | reg_w(sd, 0x40 + i, a); |
156 | reg_w(sd, 0x60 + i, b); | 163 | reg_w(sd, 0x60 + i, b); |
157 | } | 164 | } |
158 | ret += reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */ | 165 | reg_w(sd, 0x39, 0x0012); /* JPEG encoder enable */ |
159 | |||
160 | return ret; | ||
161 | } | 166 | } |
162 | 167 | ||
163 | /**************************************************************************** | 168 | /**************************************************************************** |
@@ -168,50 +173,39 @@ static int w9968cf_upload_quantizationtables(struct sd *sd) | |||
168 | * i2c_adap_read_byte() * | 173 | * i2c_adap_read_byte() * |
169 | ****************************************************************************/ | 174 | ****************************************************************************/ |
170 | 175 | ||
171 | static int w9968cf_smbus_start(struct sd *sd) | 176 | static void w9968cf_smbus_start(struct sd *sd) |
172 | { | 177 | { |
173 | int ret = 0; | 178 | w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ |
174 | 179 | w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | |
175 | ret += w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | ||
176 | ret += w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | ||
177 | |||
178 | return ret; | ||
179 | } | 180 | } |
180 | 181 | ||
181 | static int w9968cf_smbus_stop(struct sd *sd) | 182 | static void w9968cf_smbus_stop(struct sd *sd) |
182 | { | 183 | { |
183 | int ret = 0; | 184 | w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ |
184 | 185 | w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | |
185 | ret += w9968cf_write_sb(sd, 0x0010); /* SDE=1, SDA=0, SCL=0 */ | 186 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
186 | ret += w9968cf_write_sb(sd, 0x0011); /* SDE=1, SDA=0, SCL=1 */ | ||
187 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | ||
188 | |||
189 | return ret; | ||
190 | } | 187 | } |
191 | 188 | ||
192 | static int w9968cf_smbus_write_byte(struct sd *sd, u8 v) | 189 | static void w9968cf_smbus_write_byte(struct sd *sd, u8 v) |
193 | { | 190 | { |
194 | u8 bit; | 191 | u8 bit; |
195 | int ret = 0, sda; | 192 | int sda; |
196 | 193 | ||
197 | for (bit = 0 ; bit < 8 ; bit++) { | 194 | for (bit = 0 ; bit < 8 ; bit++) { |
198 | sda = (v & 0x80) ? 2 : 0; | 195 | sda = (v & 0x80) ? 2 : 0; |
199 | v <<= 1; | 196 | v <<= 1; |
200 | /* SDE=1, SDA=sda, SCL=0 */ | 197 | /* SDE=1, SDA=sda, SCL=0 */ |
201 | ret += w9968cf_write_sb(sd, 0x10 | sda); | 198 | w9968cf_write_sb(sd, 0x10 | sda); |
202 | /* SDE=1, SDA=sda, SCL=1 */ | 199 | /* SDE=1, SDA=sda, SCL=1 */ |
203 | ret += w9968cf_write_sb(sd, 0x11 | sda); | 200 | w9968cf_write_sb(sd, 0x11 | sda); |
204 | /* SDE=1, SDA=sda, SCL=0 */ | 201 | /* SDE=1, SDA=sda, SCL=0 */ |
205 | ret += w9968cf_write_sb(sd, 0x10 | sda); | 202 | w9968cf_write_sb(sd, 0x10 | sda); |
206 | } | 203 | } |
207 | |||
208 | return ret; | ||
209 | } | 204 | } |
210 | 205 | ||
211 | static int w9968cf_smbus_read_byte(struct sd *sd, u8* v) | 206 | static void w9968cf_smbus_read_byte(struct sd *sd, u8 *v) |
212 | { | 207 | { |
213 | u8 bit; | 208 | u8 bit; |
214 | int ret = 0; | ||
215 | 209 | ||
216 | /* No need to ensure SDA is high as we are always called after | 210 | /* No need to ensure SDA is high as we are always called after |
217 | read_ack which ends with SDA high */ | 211 | read_ack which ends with SDA high */ |
@@ -219,51 +213,40 @@ static int w9968cf_smbus_read_byte(struct sd *sd, u8* v) | |||
219 | for (bit = 0 ; bit < 8 ; bit++) { | 213 | for (bit = 0 ; bit < 8 ; bit++) { |
220 | *v <<= 1; | 214 | *v <<= 1; |
221 | /* SDE=1, SDA=1, SCL=1 */ | 215 | /* SDE=1, SDA=1, SCL=1 */ |
222 | ret += w9968cf_write_sb(sd, 0x0013); | 216 | w9968cf_write_sb(sd, 0x0013); |
223 | *v |= (w9968cf_read_sb(sd) & 0x0008) ? 1 : 0; | 217 | *v |= (w9968cf_read_sb(sd) & 0x0008) ? 1 : 0; |
224 | /* SDE=1, SDA=1, SCL=0 */ | 218 | /* SDE=1, SDA=1, SCL=0 */ |
225 | ret += w9968cf_write_sb(sd, 0x0012); | 219 | w9968cf_write_sb(sd, 0x0012); |
226 | } | 220 | } |
227 | |||
228 | return ret; | ||
229 | } | 221 | } |
230 | 222 | ||
231 | static int w9968cf_smbus_write_nack(struct sd *sd) | 223 | static void w9968cf_smbus_write_nack(struct sd *sd) |
232 | { | 224 | { |
233 | int ret = 0; | ||
234 | |||
235 | /* No need to ensure SDA is high as we are always called after | 225 | /* No need to ensure SDA is high as we are always called after |
236 | read_byte which ends with SDA high */ | 226 | read_byte which ends with SDA high */ |
237 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | 227 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
238 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 228 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
239 | |||
240 | return ret; | ||
241 | } | 229 | } |
242 | 230 | ||
243 | static int w9968cf_smbus_read_ack(struct sd *sd) | 231 | static void w9968cf_smbus_read_ack(struct sd *sd) |
244 | { | 232 | { |
245 | int ret = 0, sda; | 233 | int sda; |
246 | 234 | ||
247 | /* Ensure SDA is high before raising clock to avoid a spurious stop */ | 235 | /* Ensure SDA is high before raising clock to avoid a spurious stop */ |
248 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 236 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
249 | ret += w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ | 237 | w9968cf_write_sb(sd, 0x0013); /* SDE=1, SDA=1, SCL=1 */ |
250 | sda = w9968cf_read_sb(sd); | 238 | sda = w9968cf_read_sb(sd); |
251 | ret += w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ | 239 | w9968cf_write_sb(sd, 0x0012); /* SDE=1, SDA=1, SCL=0 */ |
252 | if (sda < 0) | 240 | if (sda >= 0 && (sda & 0x08)) { |
253 | ret += sda; | ||
254 | else if (sda & 0x08) { | ||
255 | PDEBUG(D_USBI, "Did not receive i2c ACK"); | 241 | PDEBUG(D_USBI, "Did not receive i2c ACK"); |
256 | ret += -1; | 242 | sd->gspca_dev.usb_err = -EIO; |
257 | } | 243 | } |
258 | |||
259 | return ret; | ||
260 | } | 244 | } |
261 | 245 | ||
262 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ | 246 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */ |
263 | static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | 247 | static void w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) |
264 | { | 248 | { |
265 | u16* data = (u16 *)sd->gspca_dev.usb_buf; | 249 | u16* data = (u16 *)sd->gspca_dev.usb_buf; |
266 | int ret = 0; | ||
267 | 250 | ||
268 | data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0); | 251 | data[0] = 0x082f | ((sd->sensor_addr & 0x80) ? 0x1500 : 0x0); |
269 | data[0] |= (sd->sensor_addr & 0x40) ? 0x4000 : 0x0; | 252 | data[0] |= (sd->sensor_addr & 0x40) ? 0x4000 : 0x0; |
@@ -276,7 +259,7 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
276 | data[3] = 0x1d20 | ((sd->sensor_addr & 0x02) ? 0x0001 : 0x0); | 259 | data[3] = 0x1d20 | ((sd->sensor_addr & 0x02) ? 0x0001 : 0x0); |
277 | data[3] |= (sd->sensor_addr & 0x01) ? 0x0054 : 0x0; | 260 | data[3] |= (sd->sensor_addr & 0x01) ? 0x0054 : 0x0; |
278 | 261 | ||
279 | ret += w9968cf_write_fsb(sd, data); | 262 | w9968cf_write_fsb(sd, data); |
280 | 263 | ||
281 | data[0] = 0x8208 | ((reg & 0x80) ? 0x0015 : 0x0); | 264 | data[0] = 0x8208 | ((reg & 0x80) ? 0x0015 : 0x0); |
282 | data[0] |= (reg & 0x40) ? 0x0540 : 0x0; | 265 | data[0] |= (reg & 0x40) ? 0x0540 : 0x0; |
@@ -290,7 +273,7 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
290 | data[2] |= (reg & 0x01) ? 0x5400 : 0x0; | 273 | data[2] |= (reg & 0x01) ? 0x5400 : 0x0; |
291 | data[3] = 0x001d; | 274 | data[3] = 0x001d; |
292 | 275 | ||
293 | ret += w9968cf_write_fsb(sd, data); | 276 | w9968cf_write_fsb(sd, data); |
294 | 277 | ||
295 | data[0] = 0x8208 | ((value & 0x80) ? 0x0015 : 0x0); | 278 | data[0] = 0x8208 | ((value & 0x80) ? 0x0015 : 0x0); |
296 | data[0] |= (value & 0x40) ? 0x0540 : 0x0; | 279 | data[0] |= (value & 0x40) ? 0x0540 : 0x0; |
@@ -304,14 +287,9 @@ static int w9968cf_i2c_w(struct sd *sd, u8 reg, u8 value) | |||
304 | data[2] |= (value & 0x01) ? 0x5400 : 0x0; | 287 | data[2] |= (value & 0x01) ? 0x5400 : 0x0; |
305 | data[3] = 0xfe1d; | 288 | data[3] = 0xfe1d; |
306 | 289 | ||
307 | ret += w9968cf_write_fsb(sd, data); | 290 | w9968cf_write_fsb(sd, data); |
308 | |||
309 | if (!ret) | ||
310 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); | ||
311 | else | ||
312 | PDEBUG(D_ERR, "i2c 0x%02x -> [0x%02x] failed", value, reg); | ||
313 | 291 | ||
314 | return ret; | 292 | PDEBUG(D_USBO, "i2c 0x%02x -> [0x%02x]", value, reg); |
315 | } | 293 | } |
316 | 294 | ||
317 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ | 295 | /* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */ |
@@ -321,28 +299,28 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) | |||
321 | u8 value; | 299 | u8 value; |
322 | 300 | ||
323 | /* Fast serial bus data control disable */ | 301 | /* Fast serial bus data control disable */ |
324 | ret += w9968cf_write_sb(sd, 0x0013); /* don't change ! */ | 302 | w9968cf_write_sb(sd, 0x0013); /* don't change ! */ |
325 | 303 | ||
326 | ret += w9968cf_smbus_start(sd); | 304 | w9968cf_smbus_start(sd); |
327 | ret += w9968cf_smbus_write_byte(sd, sd->sensor_addr); | 305 | w9968cf_smbus_write_byte(sd, sd->sensor_addr); |
328 | ret += w9968cf_smbus_read_ack(sd); | 306 | w9968cf_smbus_read_ack(sd); |
329 | ret += w9968cf_smbus_write_byte(sd, reg); | 307 | w9968cf_smbus_write_byte(sd, reg); |
330 | ret += w9968cf_smbus_read_ack(sd); | 308 | w9968cf_smbus_read_ack(sd); |
331 | ret += w9968cf_smbus_stop(sd); | 309 | w9968cf_smbus_stop(sd); |
332 | ret += w9968cf_smbus_start(sd); | 310 | w9968cf_smbus_start(sd); |
333 | ret += w9968cf_smbus_write_byte(sd, sd->sensor_addr + 1); | 311 | w9968cf_smbus_write_byte(sd, sd->sensor_addr + 1); |
334 | ret += w9968cf_smbus_read_ack(sd); | 312 | w9968cf_smbus_read_ack(sd); |
335 | ret += w9968cf_smbus_read_byte(sd, &value); | 313 | w9968cf_smbus_read_byte(sd, &value); |
336 | /* signal we don't want to read anymore, the v4l1 driver used to | 314 | /* signal we don't want to read anymore, the v4l1 driver used to |
337 | send an ack here which is very wrong! (and then fixed | 315 | send an ack here which is very wrong! (and then fixed |
338 | the issues this gave by retrying reads) */ | 316 | the issues this gave by retrying reads) */ |
339 | ret += w9968cf_smbus_write_nack(sd); | 317 | w9968cf_smbus_write_nack(sd); |
340 | ret += w9968cf_smbus_stop(sd); | 318 | w9968cf_smbus_stop(sd); |
341 | 319 | ||
342 | /* Fast serial bus data control re-enable */ | 320 | /* Fast serial bus data control re-enable */ |
343 | ret += w9968cf_write_sb(sd, 0x0030); | 321 | w9968cf_write_sb(sd, 0x0030); |
344 | 322 | ||
345 | if (!ret) { | 323 | if (sd->gspca_dev.usb_err >= 0) { |
346 | ret = value; | 324 | ret = value; |
347 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); | 325 | PDEBUG(D_USBI, "i2c [0x%02X] -> 0x%02X", reg, value); |
348 | } else | 326 | } else |
@@ -355,29 +333,21 @@ static int w9968cf_i2c_r(struct sd *sd, u8 reg) | |||
355 | Turn on the LED on some webcams. A beep should be heard too. | 333 | Turn on the LED on some webcams. A beep should be heard too. |
356 | Return 0 on success, a negative number otherwise. | 334 | Return 0 on success, a negative number otherwise. |
357 | --------------------------------------------------------------------------*/ | 335 | --------------------------------------------------------------------------*/ |
358 | static int w9968cf_configure(struct sd *sd) | 336 | static void w9968cf_configure(struct sd *sd) |
359 | { | 337 | { |
360 | int ret = 0; | 338 | reg_w(sd, 0x00, 0xff00); /* power-down */ |
361 | 339 | reg_w(sd, 0x00, 0xbf17); /* reset everything */ | |
362 | ret += reg_w(sd, 0x00, 0xff00); /* power-down */ | 340 | reg_w(sd, 0x00, 0xbf10); /* normal operation */ |
363 | ret += reg_w(sd, 0x00, 0xbf17); /* reset everything */ | 341 | reg_w(sd, 0x01, 0x0010); /* serial bus, SDS high */ |
364 | ret += reg_w(sd, 0x00, 0xbf10); /* normal operation */ | 342 | reg_w(sd, 0x01, 0x0000); /* serial bus, SDS low */ |
365 | ret += reg_w(sd, 0x01, 0x0010); /* serial bus, SDS high */ | 343 | reg_w(sd, 0x01, 0x0010); /* ..high 'beep-beep' */ |
366 | ret += reg_w(sd, 0x01, 0x0000); /* serial bus, SDS low */ | 344 | reg_w(sd, 0x01, 0x0030); /* Set sda scl to FSB mode */ |
367 | ret += reg_w(sd, 0x01, 0x0010); /* ..high 'beep-beep' */ | ||
368 | ret += reg_w(sd, 0x01, 0x0030); /* Set sda scl to FSB mode */ | ||
369 | |||
370 | if (ret) | ||
371 | PDEBUG(D_ERR, "Couldn't turn on the LED"); | ||
372 | 345 | ||
373 | sd->stopped = 1; | 346 | sd->stopped = 1; |
374 | |||
375 | return ret; | ||
376 | } | 347 | } |
377 | 348 | ||
378 | static int w9968cf_init(struct sd *sd) | 349 | static void w9968cf_init(struct sd *sd) |
379 | { | 350 | { |
380 | int ret = 0; | ||
381 | unsigned long hw_bufsize = sd->sif ? (352 * 288 * 2) : (640 * 480 * 2), | 351 | unsigned long hw_bufsize = sd->sif ? (352 * 288 * 2) : (640 * 480 * 2), |
382 | y0 = 0x0000, | 352 | y0 = 0x0000, |
383 | u0 = y0 + hw_bufsize / 2, | 353 | u0 = y0 + hw_bufsize / 2, |
@@ -386,43 +356,41 @@ static int w9968cf_init(struct sd *sd) | |||
386 | u1 = y1 + hw_bufsize / 2, | 356 | u1 = y1 + hw_bufsize / 2, |
387 | v1 = u1 + hw_bufsize / 4; | 357 | v1 = u1 + hw_bufsize / 4; |
388 | 358 | ||
389 | ret += reg_w(sd, 0x00, 0xff00); /* power off */ | 359 | reg_w(sd, 0x00, 0xff00); /* power off */ |
390 | ret += reg_w(sd, 0x00, 0xbf10); /* power on */ | 360 | reg_w(sd, 0x00, 0xbf10); /* power on */ |
391 | |||
392 | ret += reg_w(sd, 0x03, 0x405d); /* DRAM timings */ | ||
393 | ret += reg_w(sd, 0x04, 0x0030); /* SDRAM timings */ | ||
394 | 361 | ||
395 | ret += reg_w(sd, 0x20, y0 & 0xffff); /* Y buf.0, low */ | 362 | reg_w(sd, 0x03, 0x405d); /* DRAM timings */ |
396 | ret += reg_w(sd, 0x21, y0 >> 16); /* Y buf.0, high */ | 363 | reg_w(sd, 0x04, 0x0030); /* SDRAM timings */ |
397 | ret += reg_w(sd, 0x24, u0 & 0xffff); /* U buf.0, low */ | ||
398 | ret += reg_w(sd, 0x25, u0 >> 16); /* U buf.0, high */ | ||
399 | ret += reg_w(sd, 0x28, v0 & 0xffff); /* V buf.0, low */ | ||
400 | ret += reg_w(sd, 0x29, v0 >> 16); /* V buf.0, high */ | ||
401 | 364 | ||
402 | ret += reg_w(sd, 0x22, y1 & 0xffff); /* Y buf.1, low */ | 365 | reg_w(sd, 0x20, y0 & 0xffff); /* Y buf.0, low */ |
403 | ret += reg_w(sd, 0x23, y1 >> 16); /* Y buf.1, high */ | 366 | reg_w(sd, 0x21, y0 >> 16); /* Y buf.0, high */ |
404 | ret += reg_w(sd, 0x26, u1 & 0xffff); /* U buf.1, low */ | 367 | reg_w(sd, 0x24, u0 & 0xffff); /* U buf.0, low */ |
405 | ret += reg_w(sd, 0x27, u1 >> 16); /* U buf.1, high */ | 368 | reg_w(sd, 0x25, u0 >> 16); /* U buf.0, high */ |
406 | ret += reg_w(sd, 0x2a, v1 & 0xffff); /* V buf.1, low */ | 369 | reg_w(sd, 0x28, v0 & 0xffff); /* V buf.0, low */ |
407 | ret += reg_w(sd, 0x2b, v1 >> 16); /* V buf.1, high */ | 370 | reg_w(sd, 0x29, v0 >> 16); /* V buf.0, high */ |
408 | 371 | ||
409 | ret += reg_w(sd, 0x32, y1 & 0xffff); /* JPEG buf 0 low */ | 372 | reg_w(sd, 0x22, y1 & 0xffff); /* Y buf.1, low */ |
410 | ret += reg_w(sd, 0x33, y1 >> 16); /* JPEG buf 0 high */ | 373 | reg_w(sd, 0x23, y1 >> 16); /* Y buf.1, high */ |
374 | reg_w(sd, 0x26, u1 & 0xffff); /* U buf.1, low */ | ||
375 | reg_w(sd, 0x27, u1 >> 16); /* U buf.1, high */ | ||
376 | reg_w(sd, 0x2a, v1 & 0xffff); /* V buf.1, low */ | ||
377 | reg_w(sd, 0x2b, v1 >> 16); /* V buf.1, high */ | ||
411 | 378 | ||
412 | ret += reg_w(sd, 0x34, y1 & 0xffff); /* JPEG buf 1 low */ | 379 | reg_w(sd, 0x32, y1 & 0xffff); /* JPEG buf 0 low */ |
413 | ret += reg_w(sd, 0x35, y1 >> 16); /* JPEG bug 1 high */ | 380 | reg_w(sd, 0x33, y1 >> 16); /* JPEG buf 0 high */ |
414 | 381 | ||
415 | ret += reg_w(sd, 0x36, 0x0000);/* JPEG restart interval */ | 382 | reg_w(sd, 0x34, y1 & 0xffff); /* JPEG buf 1 low */ |
416 | ret += reg_w(sd, 0x37, 0x0804);/*JPEG VLE FIFO threshold*/ | 383 | reg_w(sd, 0x35, y1 >> 16); /* JPEG bug 1 high */ |
417 | ret += reg_w(sd, 0x38, 0x0000);/* disable hw up-scaling */ | ||
418 | ret += reg_w(sd, 0x3f, 0x0000); /* JPEG/MCTL test data */ | ||
419 | 384 | ||
420 | return ret; | 385 | reg_w(sd, 0x36, 0x0000);/* JPEG restart interval */ |
386 | reg_w(sd, 0x37, 0x0804);/*JPEG VLE FIFO threshold*/ | ||
387 | reg_w(sd, 0x38, 0x0000);/* disable hw up-scaling */ | ||
388 | reg_w(sd, 0x3f, 0x0000); /* JPEG/MCTL test data */ | ||
421 | } | 389 | } |
422 | 390 | ||
423 | static int w9968cf_set_crop_window(struct sd *sd) | 391 | static void w9968cf_set_crop_window(struct sd *sd) |
424 | { | 392 | { |
425 | int ret = 0, start_cropx, start_cropy, x, y, fw, fh, cw, ch, | 393 | int start_cropx, start_cropy, x, y, fw, fh, cw, ch, |
426 | max_width, max_height; | 394 | max_width, max_height; |
427 | 395 | ||
428 | if (sd->sif) { | 396 | if (sd->sif) { |
@@ -464,42 +432,40 @@ static int w9968cf_set_crop_window(struct sd *sd) | |||
464 | x = (max_width - cw) / 2; | 432 | x = (max_width - cw) / 2; |
465 | y = (max_height - ch) / 2; | 433 | y = (max_height - ch) / 2; |
466 | 434 | ||
467 | ret += reg_w(sd, 0x10, start_cropx + x); | 435 | reg_w(sd, 0x10, start_cropx + x); |
468 | ret += reg_w(sd, 0x11, start_cropy + y); | 436 | reg_w(sd, 0x11, start_cropy + y); |
469 | ret += reg_w(sd, 0x12, start_cropx + x + cw); | 437 | reg_w(sd, 0x12, start_cropx + x + cw); |
470 | ret += reg_w(sd, 0x13, start_cropy + y + ch); | 438 | reg_w(sd, 0x13, start_cropy + y + ch); |
471 | |||
472 | return ret; | ||
473 | } | 439 | } |
474 | 440 | ||
475 | static int w9968cf_mode_init_regs(struct sd *sd) | 441 | static void w9968cf_mode_init_regs(struct sd *sd) |
476 | { | 442 | { |
477 | int ret = 0, val, vs_polarity, hs_polarity; | 443 | int val, vs_polarity, hs_polarity; |
478 | 444 | ||
479 | ret += w9968cf_set_crop_window(sd); | 445 | w9968cf_set_crop_window(sd); |
480 | 446 | ||
481 | ret += reg_w(sd, 0x14, sd->gspca_dev.width); | 447 | reg_w(sd, 0x14, sd->gspca_dev.width); |
482 | ret += reg_w(sd, 0x15, sd->gspca_dev.height); | 448 | reg_w(sd, 0x15, sd->gspca_dev.height); |
483 | 449 | ||
484 | /* JPEG width & height */ | 450 | /* JPEG width & height */ |
485 | ret += reg_w(sd, 0x30, sd->gspca_dev.width); | 451 | reg_w(sd, 0x30, sd->gspca_dev.width); |
486 | ret += reg_w(sd, 0x31, sd->gspca_dev.height); | 452 | reg_w(sd, 0x31, sd->gspca_dev.height); |
487 | 453 | ||
488 | /* Y & UV frame buffer strides (in WORD) */ | 454 | /* Y & UV frame buffer strides (in WORD) */ |
489 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == | 455 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == |
490 | V4L2_PIX_FMT_JPEG) { | 456 | V4L2_PIX_FMT_JPEG) { |
491 | ret += reg_w(sd, 0x2c, sd->gspca_dev.width / 2); | 457 | reg_w(sd, 0x2c, sd->gspca_dev.width / 2); |
492 | ret += reg_w(sd, 0x2d, sd->gspca_dev.width / 4); | 458 | reg_w(sd, 0x2d, sd->gspca_dev.width / 4); |
493 | } else | 459 | } else |
494 | ret += reg_w(sd, 0x2c, sd->gspca_dev.width); | 460 | reg_w(sd, 0x2c, sd->gspca_dev.width); |
495 | 461 | ||
496 | ret += reg_w(sd, 0x00, 0xbf17); /* reset everything */ | 462 | reg_w(sd, 0x00, 0xbf17); /* reset everything */ |
497 | ret += reg_w(sd, 0x00, 0xbf10); /* normal operation */ | 463 | reg_w(sd, 0x00, 0xbf10); /* normal operation */ |
498 | 464 | ||
499 | /* Transfer size in WORDS (for UYVY format only) */ | 465 | /* Transfer size in WORDS (for UYVY format only) */ |
500 | val = sd->gspca_dev.width * sd->gspca_dev.height; | 466 | val = sd->gspca_dev.width * sd->gspca_dev.height; |
501 | ret += reg_w(sd, 0x3d, val & 0xffff); /* low bits */ | 467 | reg_w(sd, 0x3d, val & 0xffff); /* low bits */ |
502 | ret += reg_w(sd, 0x3e, val >> 16); /* high bits */ | 468 | reg_w(sd, 0x3e, val >> 16); /* high bits */ |
503 | 469 | ||
504 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == | 470 | if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == |
505 | V4L2_PIX_FMT_JPEG) { | 471 | V4L2_PIX_FMT_JPEG) { |
@@ -507,7 +473,7 @@ static int w9968cf_mode_init_regs(struct sd *sd) | |||
507 | jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, | 473 | jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, |
508 | sd->gspca_dev.width, 0x22); /* JPEG 420 */ | 474 | sd->gspca_dev.width, 0x22); /* JPEG 420 */ |
509 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | 475 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
510 | ret += w9968cf_upload_quantizationtables(sd); | 476 | w9968cf_upload_quantizationtables(sd); |
511 | } | 477 | } |
512 | 478 | ||
513 | /* Video Capture Control Register */ | 479 | /* Video Capture Control Register */ |
@@ -539,11 +505,9 @@ static int w9968cf_mode_init_regs(struct sd *sd) | |||
539 | 505 | ||
540 | val |= 0x8000; /* capt. enable */ | 506 | val |= 0x8000; /* capt. enable */ |
541 | 507 | ||
542 | ret += reg_w(sd, 0x16, val); | 508 | reg_w(sd, 0x16, val); |
543 | 509 | ||
544 | sd->gspca_dev.empty_packet = 0; | 510 | sd->gspca_dev.empty_packet = 0; |
545 | |||
546 | return ret; | ||
547 | } | 511 | } |
548 | 512 | ||
549 | static void w9968cf_stop0(struct sd *sd) | 513 | static void w9968cf_stop0(struct sd *sd) |