diff options
author | Firas Sammoura <fsammoura@google.com> | 2022-06-17 16:41:11 +0000 |
---|---|---|
committer | Firas Sammoura <fsammoura@google.com> | 2022-06-17 16:41:11 +0000 |
commit | 6c1587ca70f558b4f96b3f0b18ad8b027d3ba99d (patch) | |
tree | 9a15b4a98d7987870a1805a33883d0cf9123fc05 /driver/led/aw20198.c | |
parent | 63a8a1366e390b757c37e167927102be0fc4fb63 (diff) | |
parent | a46d3f3feaac0d69012f61b66f652bff991d05a7 (diff) | |
download | chrome-ec-6c1587ca70f558b4f96b3f0b18ad8b027d3ba99d.tar.gz |
Merge remote-tracking branch cros/main into firmware-fpmcu-dartmonkey-release
Generated by: ./util/update_release_branch.py --board dartmonkey --relevant_paths_file ./util/fingerprint-relevant-paths.txt firmware-fpmcu-dartmonkey-release
Relevant changes:
git log --oneline 63a8a1366e..a46d3f3fea -- board/nocturne_fp
board/dartmonkey common/fpsensor docs/fingerprint driver/fingerprint
util/getversion.sh
981fb88cf8 docs/fingerprint: Resolve contradictory FPMCU factory flashing instructions
60032a8828 docs/fingerprint: Clean up formatting in fingerprint-factory-quick-guide.md
f49eb6f894 docs/fingerprint: Run mdformat
64aa5fc7bb docs/fingerprint: Add links to info on fuzz testing
8bd99cc434 fpsensor: Use correct return type
2b2d7a991d fpsensor: Use correct return type
BRANCH=None
BUG=b:234772776 b:234181908
TEST=`make -j buildall`
Cq-Include-Trybots: chromeos/cq:cq-orchestrator
Signed-off-by: Firas Sammoura <fsammoura@google.com>
Change-Id: I1714a77d292aad81bdc71982c88b2b067cfdada7
Diffstat (limited to 'driver/led/aw20198.c')
-rw-r--r-- | driver/led/aw20198.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/driver/led/aw20198.c b/driver/led/aw20198.c index f307ae4a02..1322c08a09 100644 --- a/driver/led/aw20198.c +++ b/driver/led/aw20198.c @@ -107,13 +107,13 @@ static int aw20198_set_color(struct rgbkbd *ctx, uint8_t offset, buf, frame_len, NULL, 0); } -static int aw20198_set_scale(struct rgbkbd *ctx, uint8_t offset, uint8_t scale, - uint8_t len) +static int aw20198_set_scale(struct rgbkbd *ctx, uint8_t offset, + struct rgb_s scale, uint8_t len) { uint8_t buf[sizeof(offset) + BUF_SIZE]; const int frame_len = len * SIZE_OF_RGB + sizeof(offset); const int frame_offset = offset * SIZE_OF_RGB; - int rv; + int i, rv; if (frame_offset + frame_len > sizeof(buf)) { return EC_ERROR_OVERFLOW; @@ -124,8 +124,12 @@ static int aw20198_set_scale(struct rgbkbd *ctx, uint8_t offset, uint8_t scale, return rv; } - buf[0] = offset * SIZE_OF_RGB; - memset(&buf[1], scale, len * SIZE_OF_RGB); + buf[0] = frame_offset; + for (i = 0; i < len; i++) { + buf[i * SIZE_OF_RGB + 1] = scale.r; + buf[i * SIZE_OF_RGB + 2] = scale.g; + buf[i * SIZE_OF_RGB + 3] = scale.b; + } return i2c_xfer(ctx->cfg->i2c, AW20198_I2C_ADDR_FLAG, buf, frame_len, NULL, 0); @@ -138,18 +142,28 @@ static int aw20198_set_gcc(struct rgbkbd *ctx, uint8_t level) static int aw20198_init(struct rgbkbd *ctx) { - uint8_t id; + uint8_t u8; int rv; rv = aw20198_reset(ctx); msleep(3); /* Read chip ID, assuming page is still 0. */ - rv = aw20198_read(ctx, AW20198_REG_RSTN, &id); + rv = aw20198_read(ctx, AW20198_REG_RSTN, &u8); if (rv) { return rv; } - CPRINTS("ID=0x%02x", id); + CPRINTS("ID=0x%02x", u8); + + /* Modify SWSEL bit4-7 to match the LED layout */ + rv = aw20198_get_config(ctx, AW20198_REG_GCR, &u8); + if (rv) { + return rv; + } + u8 &= ~AW20198_REG_GCR_SWSEL_MASK; + u8 |= ((ctx->cfg->col_len - 1) << AW20198_REG_GCR_SWSEL_SHIFT); + rv = aw20198_write(ctx, AW20198_REG_GCR, u8); + CPRINTS("GCR=0x%02x", u8); return rv; } |