:::::: 
:::::: Manual check reason: "low confidence static check warning: 
drivers/media/i2c/tc358840.c:1647:3: warning: Value stored to 'have_hdcp' is 
never read [clang-analyzer-deadcode.DeadStores]"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Hans Verkuil <[email protected]>

tree:   git://linuxtv.org/hverkuil/media_tree.git tegrav8
head:   386823032a34ce7926c18033b0ca34de9145a206
commit: f51f9140626da0e72ade6bd437ac2fe13e9b0425 [2/7] tc358840: add Toshiba 
tc358840 HDMI-to-CSI bridge.
:::::: branch date: 3 weeks ago
:::::: commit date: 3 weeks ago
config: mips-randconfig-c004-20220808 
(https://download.01.org/0day-ci/archive/20220813/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 
5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mipsel-linux-gnu
        git remote add hverkuil-media-tree 
git://linuxtv.org/hverkuil/media_tree.git
        git fetch --no-tags hverkuil-media-tree tegrav8
        git checkout f51f9140626da0e72ade6bd437ac2fe13e9b0425
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 
clang-analyzer 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

clang-analyzer warnings: (new ones prefixed by >>)
                                                                    ^
   arch/mips/include/asm/bitops.h:390:44: note: Left side of '&&' is false
               __builtin_constant_p(cpu_has_clo_clz) && cpu_has_clo_clz) {
                                                     ^
   arch/mips/include/asm/bitops.h:402:2: note: The value 32 is assigned to 'r'
           r = 32;
           ^~~~~~
   arch/mips/include/asm/bitops.h:403:6: note: Assuming 'x' is not equal to 0, 
which participates in a condition later
           if (!x)
               ^~
   arch/mips/include/asm/bitops.h:403:2: note: Taking false branch
           if (!x)
           ^
   arch/mips/include/asm/bitops.h:405:6: note: Assuming the condition is false
           if (!(x & 0xffff0000u)) {
               ^~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/bitops.h:405:2: note: Taking false branch
           if (!(x & 0xffff0000u)) {
           ^
   arch/mips/include/asm/bitops.h:409:6: note: Assuming the condition is false
           if (!(x & 0xff000000u)) {
               ^~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/bitops.h:409:2: note: Taking false branch
           if (!(x & 0xff000000u)) {
           ^
   arch/mips/include/asm/bitops.h:413:6: note: Assuming the condition is false
           if (!(x & 0xf0000000u)) {
               ^~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/bitops.h:413:2: note: Taking false branch
           if (!(x & 0xf0000000u)) {
           ^
   arch/mips/include/asm/bitops.h:417:6: note: Assuming the condition is false
           if (!(x & 0xc0000000u)) {
               ^~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/bitops.h:417:2: note: Taking false branch
           if (!(x & 0xc0000000u)) {
           ^
   arch/mips/include/asm/bitops.h:421:6: note: Assuming the condition is false
           if (!(x & 0x80000000u)) {
               ^~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/bitops.h:421:2: note: Taking false branch
           if (!(x & 0x80000000u)) {
           ^
   arch/mips/include/asm/bitops.h:425:2: note: Returning the value 32 (loaded 
from 'r')
           return r;
           ^~~~~~~~
   sound/soc/codecs/wsa881x.c:749:28: note: Returning from 'fls'
           unsigned int mask = (1 << fls(max)) - 1;
                                     ^~~~~~~~
   sound/soc/codecs/wsa881x.c:749:25: note: The result of the left shift is 
undefined due to shifting by '32', which is greater or equal to the width of 
type 'int'
           unsigned int mask = (1 << fls(max)) - 1;
                                  ^  ~~~~~~~~
   Suppressed 31 warnings (31 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   56 warnings generated.
   drivers/media/i2c/tc358743.c:310:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(timings, 0, sizeof(struct v4l2_dv_timings));
           ^~~~~~
   drivers/media/i2c/tc358743.c:310:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(timings, 0, sizeof(struct v4l2_dv_timings));
           ^~~~~~
   drivers/media/i2c/tc358743.c:1192:4: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                           memset(&state->timings, 0, sizeof(state->timings));
                           ^~~~~~
   drivers/media/i2c/tc358743.c:1192:4: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
                           memset(&state->timings, 0, sizeof(state->timings));
                           ^~~~~~
   drivers/media/i2c/tc358743.c:1728:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358743.c:1728:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358743.c:1766:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358743.c:1766:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   59 warnings generated.
   drivers/media/i2c/tc358840.c:1324:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(timings, 0, sizeof(struct v4l2_dv_timings));
           ^~~~~~
   drivers/media/i2c/tc358840.c:1324:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(timings, 0, sizeof(struct v4l2_dv_timings));
           ^~~~~~
   drivers/media/i2c/tc358840.c:1382:3: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memset(timings, 0, sizeof(struct v4l2_dv_timings));
                   ^~~~~~
   drivers/media/i2c/tc358840.c:1382:3: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
                   memset(timings, 0, sizeof(struct v4l2_dv_timings));
                   ^~~~~~
   drivers/media/i2c/tc358840.c:1387:3: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memset(timings, 0, sizeof(struct v4l2_dv_timings));
                   ^~~~~~
   drivers/media/i2c/tc358840.c:1387:3: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
                   memset(timings, 0, sizeof(struct v4l2_dv_timings));
                   ^~~~~~
>> drivers/media/i2c/tc358840.c:1647:3: warning: Value stored to 'have_hdcp' is 
>> never read [clang-analyzer-deadcode.DeadStores]
                   have_hdcp = !(i2c_rd8(sd, HDCP_MODE) &
                   ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/i2c/tc358840.c:1647:3: note: Value stored to 'have_hdcp' is 
never read
                   have_hdcp = !(i2c_rd8(sd, HDCP_MODE) &
                   ^           ~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/media/i2c/tc358840.c:2221:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358840.c:2221:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358840.c:2261:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358840.c:2261:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(edid->reserved, 0, sizeof(edid->reserved));
           ^~~~~~
   drivers/media/i2c/tc358840.c:2377:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(timings->bt.reserved, 0, sizeof(timings->bt.reserved));
           ^~~~~~
   drivers/media/i2c/tc358840.c:2377:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(timings->bt.reserved, 0, sizeof(timings->bt.reserved));
           ^~~~~~
   Suppressed 52 warnings (52 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   37 warnings generated.
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   33 warnings generated.
   Suppressed 33 warnings (33 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   32 warnings generated.
   sound/soc/codecs/rt711-sdw.c:410:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(&rt711->params, params, sizeof(*params));
           ^~~~~~
   sound/soc/codecs/rt711-sdw.c:410:2: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
           memcpy(&rt711->params, params, sizeof(*params));
           ^~~~~~
   Suppressed 31 warnings (31 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   33 warnings generated.
   Suppressed 33 warnings (33 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   31 warnings generated.
   Suppressed 31 warnings (31 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   39 warnings generated.
   Suppressed 39 warnings (39 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   33 warnings generated.
   Suppressed 33 warnings (33 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   43 warnings generated.
   sound/soc/codecs/sigmadsp.c:146:3: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(ctrl->cache, data, ctrl->num_bytes);
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:146:3: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
                   memcpy(ctrl->cache, data, ctrl->num_bytes);
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:173:3: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(ucontrol->value.bytes.data, ctrl->cache,
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:173:3: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
                   memcpy(ucontrol->value.bytes.data, ctrl->cache,
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:235:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(name, ctrl_chunk->name, name_len);
           ^~~~~~
   sound/soc/codecs/sigmadsp.c:235:2: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
           memcpy(name, ctrl_chunk->name, name_len);
           ^~~~~~
   sound/soc/codecs/sigmadsp.c:282:2: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memcpy(data->data, data_chunk->data, length);
           ^~~~~~
   sound/soc/codecs/sigmadsp.c:282:2: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
           memcpy(data->data, data_chunk->data, length);
           ^~~~~~
   sound/soc/codecs/sigmadsp.c:424:3: warning: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
                   memcpy(data->data, sa->payload, data->length);
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:424:3: note: Call to function 'memcpy' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memcpy_s' in case of C11
                   memcpy(data->data, sa->payload, data->length);
                   ^~~~~~
   sound/soc/codecs/sigmadsp.c:649:2: warning: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           memset(&template, 0, sizeof(template));
           ^~~~~~
   sound/soc/codecs/sigmadsp.c:649:2: note: Call to function 'memset' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'memset_s' in case of C11
           memset(&template, 0, sizeof(template));
           ^~~~~~
   Suppressed 37 warnings (37 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   32 warnings generated.
   drivers/soundwire/debugfs.c:22:2: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
           ^~~~~~~~
   drivers/soundwire/debugfs.c:22:2: note: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11
           snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
           ^~~~~~~~
   drivers/soundwire/debugfs.c:130:2: warning: Call to function 'snprintf' is 
insecure as it does not provide security checks introduced in the C11 standard. 
Replace with analogous functions that support length arguments or provides 
boundary checks such as 'snprintf_s' in case of C11 
[clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
           snprintf(name, sizeof(name), "%s", dev_name(&slave->dev));

vim +/have_hdcp +1647 drivers/media/i2c/tc358840.c

f51f9140626da0 Hans Verkuil 2020-02-21  1608  
f51f9140626da0 Hans Verkuil 2020-02-21  1609  static void 
tc358840_delayed_work_poll(struct work_struct *work)
f51f9140626da0 Hans Verkuil 2020-02-21  1610  {
f51f9140626da0 Hans Verkuil 2020-02-21  1611    struct delayed_work *dwork = 
to_delayed_work(work);
f51f9140626da0 Hans Verkuil 2020-02-21  1612    struct tc358840_state *state = 
container_of(dwork,
f51f9140626da0 Hans Verkuil 2020-02-21  1613            struct tc358840_state, 
delayed_work_poll);
f51f9140626da0 Hans Verkuil 2020-02-21  1614    struct v4l2_subdev *sd = 
&state->sd;
f51f9140626da0 Hans Verkuil 2020-02-21  1615    u8 sys_status;
f51f9140626da0 Hans Verkuil 2020-02-21  1616    bool have_5v;
f51f9140626da0 Hans Verkuil 2020-02-21  1617    bool have_tmds;
f51f9140626da0 Hans Verkuil 2020-02-21  1618    bool have_sync;
f51f9140626da0 Hans Verkuil 2020-02-21  1619    bool have_signal;
f51f9140626da0 Hans Verkuil 2020-02-21  1620    bool have_hdcp;
f51f9140626da0 Hans Verkuil 2020-02-21  1621    unsigned int format_change = 0;
f51f9140626da0 Hans Verkuil 2020-02-21  1622  
f51f9140626da0 Hans Verkuil 2020-02-21  1623    mutex_lock(&state->lock);
f51f9140626da0 Hans Verkuil 2020-02-21  1624  
f51f9140626da0 Hans Verkuil 2020-02-21  1625    sys_status = i2c_rd8(sd, 
SYS_STATUS);
f51f9140626da0 Hans Verkuil 2020-02-21  1626    have_5v = state->test_pattern 
|| (sys_status & MASK_S_DDC5V);
f51f9140626da0 Hans Verkuil 2020-02-21  1627    have_tmds = state->test_pattern 
|| (sys_status & MASK_S_TMDS);
f51f9140626da0 Hans Verkuil 2020-02-21  1628    have_sync = state->test_pattern 
|| (sys_status & MASK_S_SYNC);
f51f9140626da0 Hans Verkuil 2020-02-21  1629    have_signal = have_5v && 
have_tmds && have_sync;
f51f9140626da0 Hans Verkuil 2020-02-21  1630    have_hdcp = have_signal ? 
(sys_status & MASK_S_HDCP) : false;
f51f9140626da0 Hans Verkuil 2020-02-21  1631  
f51f9140626da0 Hans Verkuil 2020-02-21  1632    tc358840_check_5v(sd, have_5v);
f51f9140626da0 Hans Verkuil 2020-02-21  1633    if (have_hdcp) {
f51f9140626da0 Hans Verkuil 2020-02-21  1634            /*
f51f9140626da0 Hans Verkuil 2020-02-21  1635             * MASK_S_HDCP can be 1 
for a short time when connecting
f51f9140626da0 Hans Verkuil 2020-02-21  1636             * or disconnecting: 
the HDCP authentication will kick in
f51f9140626da0 Hans Verkuil 2020-02-21  1637             * when that happens 
and thus MASK_S_HDCP becomes 1 until
f51f9140626da0 Hans Verkuil 2020-02-21  1638             * the authentication 
fails and it is cleared again.
f51f9140626da0 Hans Verkuil 2020-02-21  1639             *
f51f9140626da0 Hans Verkuil 2020-02-21  1640             * So if it is set, 
then double check that the HDCP_MODE
f51f9140626da0 Hans Verkuil 2020-02-21  1641             * is in manual 
authentication mode, because then we know
f51f9140626da0 Hans Verkuil 2020-02-21  1642             * the authentication 
will fail and this is just a glitch.
f51f9140626da0 Hans Verkuil 2020-02-21  1643             *
f51f9140626da0 Hans Verkuil 2020-02-21  1644             * Don't rely on some 
global setting, actually read the
f51f9140626da0 Hans Verkuil 2020-02-21  1645             * register here. This 
in case someone has been hacking.
f51f9140626da0 Hans Verkuil 2020-02-21  1646             */
f51f9140626da0 Hans Verkuil 2020-02-21 @1647            have_hdcp = 
!(i2c_rd8(sd, HDCP_MODE) &
f51f9140626da0 Hans Verkuil 2020-02-21  1648                          
MASK_MANUAL_AUTHENTICATION);
f51f9140626da0 Hans Verkuil 2020-02-21  1649    }
f51f9140626da0 Hans Verkuil 2020-02-21  1650  
f51f9140626da0 Hans Verkuil 2020-02-21  1651    if (!have_5v) {
f51f9140626da0 Hans Verkuil 2020-02-21  1652            
state->invalid_eq_bypass[0] = false;
f51f9140626da0 Hans Verkuil 2020-02-21  1653            
state->invalid_eq_bypass[1] = false;
f51f9140626da0 Hans Verkuil 2020-02-21  1654    }
f51f9140626da0 Hans Verkuil 2020-02-21  1655    if (state->test_pattern) {
f51f9140626da0 Hans Verkuil 2020-02-21  1656            
state->found_stable_signal = true;
f51f9140626da0 Hans Verkuil 2020-02-21  1657            state->status = 
STATUS_STABLE_SIGNAL;
f51f9140626da0 Hans Verkuil 2020-02-21  1658    } else {
f51f9140626da0 Hans Verkuil 2020-02-21  1659            u8 sys_int = 
i2c_rd8(sd, SYS_INT);
f51f9140626da0 Hans Verkuil 2020-02-21  1660            u8 clk_int = 
i2c_rd8(sd, CLK_INT);
f51f9140626da0 Hans Verkuil 2020-02-21  1661            u8 misc_int = 
i2c_rd8(sd, MISC_INT);
f51f9140626da0 Hans Verkuil 2020-02-21  1662            bool was_stable = 
state->found_stable_signal;
f51f9140626da0 Hans Verkuil 2020-02-21  1663  
f51f9140626da0 Hans Verkuil 2020-02-21  1664            i2c_wr8(sd, MISC_INT, 
0xff);
f51f9140626da0 Hans Verkuil 2020-02-21  1665            i2c_wr8(sd, CLK_INT, 
0xff);
f51f9140626da0 Hans Verkuil 2020-02-21  1666            i2c_wr8(sd, SYS_INT, 
0xff);
f51f9140626da0 Hans Verkuil 2020-02-21  1667            v4l2_dbg(2, debug, sd,
f51f9140626da0 Hans Verkuil 2020-02-21  1668                     "%s: sys_stat: 
%02x misc_int: %02x clk_int: %02x sys_int: %02x eq_byps: %s\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1669                     __func__, 
sys_status, misc_int, clk_int, sys_int,
f51f9140626da0 Hans Verkuil 2020-02-21  1670                     
state->eq_bypass ? "on" : "off");
f51f9140626da0 Hans Verkuil 2020-02-21  1671  
f51f9140626da0 Hans Verkuil 2020-02-21  1672            if (!have_sync)
f51f9140626da0 Hans Verkuil 2020-02-21  1673                    format_change 
|= 1;
f51f9140626da0 Hans Verkuil 2020-02-21  1674            if (sys_int & (MASK_DVI 
| MASK_HDMI))
f51f9140626da0 Hans Verkuil 2020-02-21  1675                    format_change 
|= 2;
f51f9140626da0 Hans Verkuil 2020-02-21  1676            if (clk_int & 
(MASK_IN_DE_CHG))
f51f9140626da0 Hans Verkuil 2020-02-21  1677                    format_change 
|= 4;
f51f9140626da0 Hans Verkuil 2020-02-21  1678            if (misc_int & 
(MASK_SYNC_CHG))
f51f9140626da0 Hans Verkuil 2020-02-21  1679                    format_change 
|= 8;
f51f9140626da0 Hans Verkuil 2020-02-21  1680  
f51f9140626da0 Hans Verkuil 2020-02-21  1681            if (sys_int & 
MASK_HDMI) {
f51f9140626da0 Hans Verkuil 2020-02-21  1682                    v4l2_dbg(1, 
debug, sd, "%s: DVI->HDMI change detected\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1683                             
__func__);
f51f9140626da0 Hans Verkuil 2020-02-21  1684  
f51f9140626da0 Hans Verkuil 2020-02-21  1685                    i2c_wr8(sd, 
APPL_CTL, MASK_APLL_CPCTL_NORMAL | MASK_APLL_ON);
f51f9140626da0 Hans Verkuil 2020-02-21  1686            }
f51f9140626da0 Hans Verkuil 2020-02-21  1687            if (sys_int & MASK_DVI) 
{
f51f9140626da0 Hans Verkuil 2020-02-21  1688                    v4l2_dbg(1, 
debug, sd, "%s: HDMI->DVI change detected\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1689                             
__func__);
f51f9140626da0 Hans Verkuil 2020-02-21  1690            }
f51f9140626da0 Hans Verkuil 2020-02-21  1691            if (!have_signal) {
f51f9140626da0 Hans Verkuil 2020-02-21  1692                    if 
(state->status != STATUS_FIND_SIGNAL)
f51f9140626da0 Hans Verkuil 2020-02-21  1693                            
v4l2_info(sd, "no signal for EQ_BYPS %d\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1694                                    
  state->eq_bypass);
f51f9140626da0 Hans Verkuil 2020-02-21  1695                    state->status = 
STATUS_FIND_SIGNAL;
f51f9140626da0 Hans Verkuil 2020-02-21  1696                    
state->found_signal_cnt[0] = 0;
f51f9140626da0 Hans Verkuil 2020-02-21  1697                    
state->found_signal_cnt[1] = 0;
f51f9140626da0 Hans Verkuil 2020-02-21  1698                    if 
(state->enabled)
f51f9140626da0 Hans Verkuil 2020-02-21  1699                            
enable_stream(sd, false);
f51f9140626da0 Hans Verkuil 2020-02-21  1700                    if 
(state->found_stable_signal) {
f51f9140626da0 Hans Verkuil 2020-02-21  1701                            
state->found_stable_signal = false;
f51f9140626da0 Hans Verkuil 2020-02-21  1702                            
v4l2_subdev_notify_event(sd, &tc358840_ev_fmt);
f51f9140626da0 Hans Verkuil 2020-02-21  1703                            
v4l2_info(sd, "event: no signal (SYS_STATUS 0x%02x)\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1704                                    
  sys_status);
f51f9140626da0 Hans Verkuil 2020-02-21  1705                    }
f51f9140626da0 Hans Verkuil 2020-02-21  1706                    
state->detected_timings.bt.width = 0;
f51f9140626da0 Hans Verkuil 2020-02-21  1707            }
f51f9140626da0 Hans Verkuil 2020-02-21  1708            /*
f51f9140626da0 Hans Verkuil 2020-02-21  1709             * Reset the HDMI PHY 
to try to trigger proper lock on the
f51f9140626da0 Hans Verkuil 2020-02-21  1710             * incoming video 
format. Erase BKSV to prevent that old keys
f51f9140626da0 Hans Verkuil 2020-02-21  1711             * are used when a new 
source is connected.
f51f9140626da0 Hans Verkuil 2020-02-21  1712             */
f51f9140626da0 Hans Verkuil 2020-02-21  1713            if (have_5v && 
(format_change & 0xa) && !have_signal) {
f51f9140626da0 Hans Verkuil 2020-02-21  1714                    if (have_tmds)
f51f9140626da0 Hans Verkuil 2020-02-21  1715                            
v4l2_dbg(was_stable ? 0 : 1, debug, sd,
f51f9140626da0 Hans Verkuil 2020-02-21  1716                                    
 "reset due to format_change (%x)\n",
f51f9140626da0 Hans Verkuil 2020-02-21  1717                                    
 format_change);
f51f9140626da0 Hans Verkuil 2020-02-21  1718                    
tc358840_reset_phy(sd);
f51f9140626da0 Hans Verkuil 2020-02-21  1719            }
f51f9140626da0 Hans Verkuil 2020-02-21  1720    }
f51f9140626da0 Hans Verkuil 2020-02-21  1721  
f51f9140626da0 Hans Verkuil 2020-02-21  1722    if (have_signal) {
f51f9140626da0 Hans Verkuil 2020-02-21  1723            struct v4l2_dv_timings 
timings = { };
f51f9140626da0 Hans Verkuil 2020-02-21  1724  
f51f9140626da0 Hans Verkuil 2020-02-21  1725            /*
f51f9140626da0 Hans Verkuil 2020-02-21  1726             * If we don't have 
detected_timings, or something changed, then
f51f9140626da0 Hans Verkuil 2020-02-21  1727             * detect timings.
f51f9140626da0 Hans Verkuil 2020-02-21  1728             */
f51f9140626da0 Hans Verkuil 2020-02-21  1729            if (format_change || 
!state->detected_timings.bt.width)
f51f9140626da0 Hans Verkuil 2020-02-21  1730                    
tc358840_get_detected_timings(sd, &timings);
f51f9140626da0 Hans Verkuil 2020-02-21  1731            else
f51f9140626da0 Hans Verkuil 2020-02-21  1732                    timings = 
state->detected_timings;
f51f9140626da0 Hans Verkuil 2020-02-21  1733  
f51f9140626da0 Hans Verkuil 2020-02-21  1734            /*
f51f9140626da0 Hans Verkuil 2020-02-21  1735             * Store newly detected 
timings (if any) if we detect timings
f51f9140626da0 Hans Verkuil 2020-02-21  1736             * for the first time, 
or if the sync toggled, or if the
f51f9140626da0 Hans Verkuil 2020-02-21  1737             * DVI/HDMI mode 
changed.
f51f9140626da0 Hans Verkuil 2020-02-21  1738             */
f51f9140626da0 Hans Verkuil 2020-02-21  1739            if 
(!state->detected_timings.bt.width || (format_change & 3)) {
f51f9140626da0 Hans Verkuil 2020-02-21  1740                    
state->detected_timings = timings;
f51f9140626da0 Hans Verkuil 2020-02-21  1741            /*
f51f9140626da0 Hans Verkuil 2020-02-21  1742             * Silently accept 
SYNC/DE changes if the timings stay the same,
f51f9140626da0 Hans Verkuil 2020-02-21  1743             * i.e. if only 
blanking changed.
f51f9140626da0 Hans Verkuil 2020-02-21  1744             */
f51f9140626da0 Hans Verkuil 2020-02-21  1745            } else if 
(format_change &&
f51f9140626da0 Hans Verkuil 2020-02-21  1746                       
tc358840_match_dv_timings(&state->detected_timings,
f51f9140626da0 Hans Verkuil 2020-02-21  1747                                    
             &timings, 250000)) {
f51f9140626da0 Hans Verkuil 2020-02-21  1748                    v4l2_dbg(1, 
debug, sd, "ignore timings change\n");
f51f9140626da0 Hans Verkuil 2020-02-21  1749                    format_change = 
0;
f51f9140626da0 Hans Verkuil 2020-02-21  1750            } else {
f51f9140626da0 Hans Verkuil 2020-02-21  1751                    
state->detected_timings = timings;
f51f9140626da0 Hans Verkuil 2020-02-21  1752            }
f51f9140626da0 Hans Verkuil 2020-02-21  1753            have_signal = 
state->detected_timings.bt.width;
f51f9140626da0 Hans Verkuil 2020-02-21  1754    }
f51f9140626da0 Hans Verkuil 2020-02-21  1755  
f51f9140626da0 Hans Verkuil 2020-02-21  1756    if (!state->test_pattern && 
have_5v) {
f51f9140626da0 Hans Verkuil 2020-02-21  1757            switch (state->status) {
f51f9140626da0 Hans Verkuil 2020-02-21  1758            case STATUS_FIND_SIGNAL:
f51f9140626da0 Hans Verkuil 2020-02-21  1759                    
tc358840_find_signal(sd, have_signal);
f51f9140626da0 Hans Verkuil 2020-02-21  1760                    break;
f51f9140626da0 Hans Verkuil 2020-02-21  1761            case 
STATUS_FOUND_SIGNAL:
f51f9140626da0 Hans Verkuil 2020-02-21  1762                    
tc358840_found_signal(sd, have_signal, format_change);
f51f9140626da0 Hans Verkuil 2020-02-21  1763                    break;
f51f9140626da0 Hans Verkuil 2020-02-21  1764            case 
STATUS_STABLE_SIGNAL:
f51f9140626da0 Hans Verkuil 2020-02-21  1765                    
tc358840_format_change(sd, have_signal, format_change);
f51f9140626da0 Hans Verkuil 2020-02-21  1766                    break;
f51f9140626da0 Hans Verkuil 2020-02-21  1767            }
f51f9140626da0 Hans Verkuil 2020-02-21  1768    }
f51f9140626da0 Hans Verkuil 2020-02-21  1769    mutex_unlock(&state->lock);
f51f9140626da0 Hans Verkuil 2020-02-21  1770    
v4l2_ctrl_s_ctrl(state->tmds_present_ctrl, have_signal);
f51f9140626da0 Hans Verkuil 2020-02-21  1771    
v4l2_ctrl_s_ctrl(state->detect_tx_5v_ctrl, have_5v);
f51f9140626da0 Hans Verkuil 2020-02-21  1772    
v4l2_ctrl_s_ctrl(state->audio_present_ctrl, audio_present(sd));
f51f9140626da0 Hans Verkuil 2020-02-21  1773  
f51f9140626da0 Hans Verkuil 2020-02-21  1774    if (have_signal)
f51f9140626da0 Hans Verkuil 2020-02-21  1775            
v4l2_ctrl_s_ctrl(state->audio_sampling_rate_ctrl,
f51f9140626da0 Hans Verkuil 2020-02-21  1776                             
get_audio_sampling_rate(sd));
f51f9140626da0 Hans Verkuil 2020-02-21  1777  
f51f9140626da0 Hans Verkuil 2020-02-21  1778    if 
(!state->delayed_work_stop_polling)
f51f9140626da0 Hans Verkuil 2020-02-21  1779            
schedule_delayed_work(&state->delayed_work_poll, POLL_PERIOD);
f51f9140626da0 Hans Verkuil 2020-02-21  1780  }
f51f9140626da0 Hans Verkuil 2020-02-21  1781  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to