Commit a6354d2e authored by HeungJun, Kim's avatar HeungJun, Kim Committed by Mauro Carvalho Chehab

[media] m5mols: remove union in the m5mols_get_version(), and VERSION_SIZE

Remove union version in the m5mols_get_version(), and read version information
directly. Also remove VERSION_SIZE.
Signed-off-by: default avatarHeungJun, Kim <riverful.kim@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 57644f56
...@@ -154,7 +154,6 @@ struct m5mols_version { ...@@ -154,7 +154,6 @@ struct m5mols_version {
u8 str[VERSION_STRING_SIZE]; u8 str[VERSION_STRING_SIZE];
u8 af; u8 af;
}; };
#define VERSION_SIZE sizeof(struct m5mols_version)
/** /**
* struct m5mols_info - M-5MOLS driver data structure * struct m5mols_info - M-5MOLS driver data structure
......
...@@ -386,37 +386,37 @@ int m5mols_mode(struct m5mols_info *info, u8 mode) ...@@ -386,37 +386,37 @@ int m5mols_mode(struct m5mols_info *info, u8 mode)
static int m5mols_get_version(struct v4l2_subdev *sd) static int m5mols_get_version(struct v4l2_subdev *sd)
{ {
struct m5mols_info *info = to_m5mols(sd); struct m5mols_info *info = to_m5mols(sd);
union { struct m5mols_version *ver = &info->ver;
struct m5mols_version ver; u8 *str = ver->str;
u8 bytes[VERSION_SIZE]; int i;
} version;
u8 cmd = CAT0_VER_CUSTOMER;
int ret; int ret;
do { ret = m5mols_read_u8(sd, SYSTEM_VER_CUSTOMER, &ver->customer);
ret = m5mols_read_u8(sd, SYSTEM_CMD(cmd), &version.bytes[cmd]); if (!ret)
if (ret) ret = m5mols_read_u8(sd, SYSTEM_VER_PROJECT, &ver->project);
return ret; if (!ret)
} while (cmd++ != CAT0_VER_AWB); ret = m5mols_read_u16(sd, SYSTEM_VER_FIRMWARE, &ver->fw);
if (!ret)
ret = m5mols_read_u16(sd, SYSTEM_VER_HARDWARE, &ver->hw);
if (!ret)
ret = m5mols_read_u16(sd, SYSTEM_VER_PARAMETER, &ver->param);
if (!ret)
ret = m5mols_read_u16(sd, SYSTEM_VER_AWB, &ver->awb);
if (!ret)
ret = m5mols_read_u8(sd, AF_VERSION, &ver->af);
if (ret)
return ret;
do { for (i = 0; i < VERSION_STRING_SIZE; i++) {
ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &version.bytes[cmd]); ret = m5mols_read_u8(sd, SYSTEM_VER_STRING, &str[i]);
if (ret) if (ret)
return ret; return ret;
if (cmd >= VERSION_SIZE - 1) }
return -EINVAL;
} while (version.bytes[cmd++]);
ret = m5mols_read_u8(sd, AF_VERSION, &version.bytes[cmd]);
if (ret)
return ret;
/* store version information swapped for being readable */ ver->fw = be16_to_cpu(ver->fw);
info->ver = version.ver; ver->hw = be16_to_cpu(ver->hw);
info->ver.fw = be16_to_cpu(info->ver.fw); ver->param = be16_to_cpu(ver->param);
info->ver.hw = be16_to_cpu(info->ver.hw); ver->awb = be16_to_cpu(ver->awb);
info->ver.param = be16_to_cpu(info->ver.param);
info->ver.awb = be16_to_cpu(info->ver.awb);
v4l2_info(sd, "Manufacturer\t[%s]\n", v4l2_info(sd, "Manufacturer\t[%s]\n",
is_manufacturer(info, REG_SAMSUNG_ELECTRO) ? is_manufacturer(info, REG_SAMSUNG_ELECTRO) ?
......
...@@ -56,13 +56,24 @@ ...@@ -56,13 +56,24 @@
* more specific contents, see definition if file m5mols.h. * more specific contents, see definition if file m5mols.h.
*/ */
#define CAT0_VER_CUSTOMER 0x00 /* customer version */ #define CAT0_VER_CUSTOMER 0x00 /* customer version */
#define CAT0_VER_AWB 0x09 /* Auto WB version */ #define CAT0_VER_PROJECT 0x01 /* project version */
#define CAT0_VER_FIRMWARE 0x02 /* Firmware version */
#define CAT0_VER_HARDWARE 0x04 /* Hardware version */
#define CAT0_VER_PARAMETER 0x06 /* Parameter version */
#define CAT0_VER_AWB 0x08 /* Auto WB version */
#define CAT0_VER_STRING 0x0a /* string including M-5MOLS */ #define CAT0_VER_STRING 0x0a /* string including M-5MOLS */
#define CAT0_SYSMODE 0x0b /* SYSTEM mode register */ #define CAT0_SYSMODE 0x0b /* SYSTEM mode register */
#define CAT0_STATUS 0x0c /* SYSTEM mode status register */ #define CAT0_STATUS 0x0c /* SYSTEM mode status register */
#define CAT0_INT_FACTOR 0x10 /* interrupt pending register */ #define CAT0_INT_FACTOR 0x10 /* interrupt pending register */
#define CAT0_INT_ENABLE 0x11 /* interrupt enable register */ #define CAT0_INT_ENABLE 0x11 /* interrupt enable register */
#define SYSTEM_VER_CUSTOMER I2C_REG(CAT_SYSTEM, CAT0_VER_CUSTOMER, 1)
#define SYSTEM_VER_PROJECT I2C_REG(CAT_SYSTEM, CAT0_VER_PROJECT, 1)
#define SYSTEM_VER_FIRMWARE I2C_REG(CAT_SYSTEM, CAT0_VER_FIRMWARE, 2)
#define SYSTEM_VER_HARDWARE I2C_REG(CAT_SYSTEM, CAT0_VER_HARDWARE, 2)
#define SYSTEM_VER_PARAMETER I2C_REG(CAT_SYSTEM, CAT0_VER_PARAMETER, 2)
#define SYSTEM_VER_AWB I2C_REG(CAT_SYSTEM, CAT0_VER_AWB, 2)
#define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1) #define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, CAT0_SYSMODE, 1)
#define REG_SYSINIT 0x00 /* SYSTEM mode */ #define REG_SYSINIT 0x00 /* SYSTEM mode */
#define REG_PARAMETER 0x01 /* PARAMETER mode */ #define REG_PARAMETER 0x01 /* PARAMETER mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment