Added the screenshots for the Sansa Clip Zip manual.
[maemo-rb.git] / firmware / drivers / synaptics-rmi.c
blobc979927feebe6d3a0297257091c86584ddd9dcab
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by Amaury Pouly
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "system.h"
22 #include "synaptics-rmi.h"
23 #include "i2c.h"
25 static int rmi_cur_page;
26 static int rmi_i2c_addr;
28 /* NOTE:
29 * RMI over i2c supports some special aliases on page 0x2 but this driver don't
30 * use them */
32 int rmi_init(int i2c_dev_addr)
34 rmi_i2c_addr = i2c_dev_addr;
35 rmi_cur_page = 0x4;
36 return 0;
39 static int rmi_select_page(unsigned char page)
41 /* Lazy page select */
42 if(page != rmi_cur_page)
44 rmi_cur_page = page;
45 return i2c_writemem(rmi_i2c_addr, RMI_PAGE_SELECT, &page, 1);
47 else
48 return 0;
51 int rmi_read(int address, int byte_count, unsigned char *buffer)
53 int ret;
54 if((ret = rmi_select_page(address >> 8)) < 0)
55 return ret;
56 return i2c_readmem(rmi_i2c_addr, address & 0xff, buffer, byte_count);
59 int rmi_read_single(int address)
61 unsigned char c;
62 int ret = rmi_read(address, 1, &c);
63 return ret < 0 ? ret : c;
66 int rmi_write(int address, int byte_count, const unsigned char *buffer)
68 int ret;
69 if((ret = rmi_select_page(address >> 8)) < 0)
70 return ret;
71 return i2c_writemem(rmi_i2c_addr, address & 0xff, buffer, byte_count);
74 int rmi_write_single(int address, unsigned char byte)
76 return rmi_write(address, 1, &byte);