You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/30 17:39:01 UTC

[incubator-nuttx] 08/11: drivers/video: Fix bug that is_available() is false

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit bea6d3a7efd5c985e8cda9928509e5b39b99239f
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Fri Dec 10 03:25:22 2021 +0900

    drivers/video: Fix bug that is_available() is false
    
    is_available() may be false because chip id register does not
    have unique value.
    So, judge availability not by chip id but by i2c accessibility.
---
 drivers/video/isx012.c     | 33 ++++++---------------------------
 drivers/video/isx012_reg.h |  2 ++
 2 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/drivers/video/isx012.c b/drivers/video/isx012.c
index 83f06d77e5..c9ada689d3 100644
--- a/drivers/video/isx012.c
+++ b/drivers/video/isx012.c
@@ -1241,39 +1241,18 @@ int init_isx012(FAR struct isx012_dev_s *priv)
   return ret;
 }
 
-static void get_chipid(uint32_t *l, uint32_t *h)
-{
-  uint16_t l1;
-  uint16_t l2;
-  uint16_t h1;
-  uint16_t h2;
-
-  ASSERT(l && h);
-
-  l1 = isx012_getreg(&g_isx012_private, OTP_CHIPID_L, 2);
-  l2 = isx012_getreg(&g_isx012_private, OTP_CHIPID_L + 2, 2);
-
-  h1 = isx012_getreg(&g_isx012_private, OTP_CHIPID_H, 2);
-  h2 = isx012_getreg(&g_isx012_private, OTP_CHIPID_H + 2, 2);
-
-  *l = (l2 << 16) | l1;
-  *h = (h2 << 16) | h1;
-}
-
 static bool isx012_is_available(void)
 {
-  bool ret = false;
-  uint32_t l;
-  uint32_t h;
+  bool ret;
 
   isx012_init();
 
-  get_chipid(&l, &h);
+  /* Try to access via I2C.
+   * Select DEVICESTS register, which has positive value.
+   */
+
+  ret = (isx012_getreg(&g_isx012_private, DEVICESTS, 1) == DEVICESTS_SLEEP);
 
-  if ((l == ISX012_CHIPID_L) && (h == ISX012_CHIPID_H))
-    {
-      ret = true;
-    }
 
   isx012_uninit();
 
diff --git a/drivers/video/isx012_reg.h b/drivers/video/isx012_reg.h
index 143d8f1d53..a30c934607 100644
--- a/drivers/video/isx012_reg.h
+++ b/drivers/video/isx012_reg.h
@@ -1401,4 +1401,6 @@
 
 #define REGVAL_INTCLR0_ALLCLEAR     (0x3F)
 
+#define DEVICESTS_SLEEP             (2)
+
 #endif /* __INCLUDE_NUTTX_VIDEO_ISX012_REG_H */