ug-2864ambag01.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  1. /****************************************************************************
  2. * drivers/lcd/ug-2864ambag01.c
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. /* Driver for Univision UG-2864AMBAG01 OLED display (with SH1101A controller)
  21. * in SPI mode
  22. *
  23. * References:
  24. * 1. Product Specification (Preliminary),
  25. * Part Name: OEL Display Module, Part ID:
  26. * UG-2864AMBAG01, Doc No: SASI-9015-A, Univision Technology Inc.
  27. * 2. SH1101A, 132 X 64 Dot Matrix OLED/PLED,
  28. * Preliminary Segment/Common Driver with
  29. * Controller, Sino Wealth
  30. */
  31. /****************************************************************************
  32. * Device memory organization:
  33. *
  34. * +----------------------------+
  35. * | Column |
  36. * --------+----+---+---+---+-...-+-----+
  37. * Page | 0 | 1 | 2 | 3 | ... | 131 |
  38. * --------+----+---+---+---+-...-+-----+
  39. * Page 0 | D0 | X | | | | |
  40. * | D1 | X | | | | |
  41. * | D2 | X | | | | |
  42. * | D3 | X | | | | |
  43. * | D4 | X | | | | |
  44. * | D5 | X | | | | |
  45. * | D6 | X | | | | |
  46. * | D7 | X | | | | |
  47. * --------+----+---+---+---+-...-+-----+
  48. * Page 1 | | | | | | |
  49. * --------+----+---+---+---+-...-+-----+
  50. * Page 2 | | | | | | |
  51. * --------+----+---+---+---+-...-+-----+
  52. * Page 3 | | | | | | |
  53. * --------+----+---+---+---+-...-+-----+
  54. * Page 4 | | | | | | |
  55. * --------+----+---+---+---+-...-+-----+
  56. * Page 5 | | | | | | |
  57. * --------+----+---+---+---+-...-+-----+
  58. * Page 6 | | | | | | |
  59. * --------+----+---+---+---+-...-+-----+
  60. * Page 7 | | | | | | |
  61. * --------+----+---+---+---+-...-+-----+
  62. *
  63. * ----------------------------------+--------------------------------------
  64. * Landscape Display: | Reverse Landscape Display:
  65. * --------+-----------------------+ | -------+---------------------------+
  66. * | Column | | | Column |
  67. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  68. * Page 0 | 0 | 1 | 2 | | 131 | | Page 7 | 131 | 130 | 129 | | 0 |
  69. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  70. * Page 1 | V | | Page 6 | ^ |
  71. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  72. * Page 2 | V | | Page 5 | ^ |
  73. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  74. * Page 3 | V | | Page 4 | ^ |
  75. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  76. * Page 4 | V | | Page 3 | ^ |
  77. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  78. * Page 5 | V | | Page 2 | ^ |
  79. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  80. * Page 6 | V | | Page 1 | ^ |
  81. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  82. * Page 7 | V | | Page 0 | ^ |
  83. * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+
  84. * ----------------------------------+--------------------------------------
  85. *
  86. * ----------------------------------+--------------------------------------
  87. * Portrait Display: | Reverse Portrait Display:
  88. * -----------+---------------------+| -----------+---------------------+
  89. * | Page || | Page |
  90. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  91. * Column 0 | 0 | 1 | 2 | | 7 || Column 131 | 7 | 6 | 5 | | 0 |
  92. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  93. * Column 1 | > > > > > || Column 130 | |
  94. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  95. * Column 2 | || Column 129 | |
  96. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  97. * ... | || ... | |
  98. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  99. * Column 131 | || Column 0 | < < < < < |
  100. * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+
  101. * ----------------------------------+--------------------------------------
  102. ****************************************************************************/
  103. /****************************************************************************
  104. * Included Files
  105. ****************************************************************************/
  106. #include <nuttx/config.h>
  107. #include <sys/types.h>
  108. #include <stdint.h>
  109. #include <stdbool.h>
  110. #include <string.h>
  111. #include <assert.h>
  112. #include <errno.h>
  113. #include <debug.h>
  114. #include <nuttx/arch.h>
  115. #include <nuttx/spi/spi.h>
  116. #include <nuttx/lcd/lcd.h>
  117. #include <nuttx/lcd/ug-2864ambag01.h>
  118. #include <arch/irq.h>
  119. #ifdef CONFIG_LCD_UG2864AMBAG01
  120. /****************************************************************************
  121. * Pre-processor Definitions
  122. ****************************************************************************/
  123. /* Configuration ************************************************************/
  124. /* Limitations of the current configuration that I hope to fix someday */
  125. #if CONFIG_UG2864AMBAG01_NINTERFACES != 1
  126. # warning "This implementation supports only a single OLED device"
  127. # undef CONFIG_UG2864AMBAG01_NINTERFACES
  128. # define CONFIG_UG2864AMBAG01_NINTERFACES 1
  129. #endif
  130. #if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT)
  131. # warning "No support yet for portrait modes"
  132. # define CONFIG_LCD_LANDSCAPE 1
  133. # undef CONFIG_LCD_PORTRAIT
  134. # undef CONFIG_LCD_RLANDSCAPE
  135. # undef CONFIG_LCD_RPORTRAIT
  136. #endif
  137. /* SH1101A Commands *********************************************************/
  138. #define SH1101A_SETCOLL(ad) (0x00 | ((ad) & 0x0f)) /* Set Lower Column Address: (00h - 0fh) */
  139. #define SH1101A_SETCOLH(ad) (0x10 | ((ad) & 0x0f)) /* Set Higher Column Address: (10h - 1fh) */
  140. #define SH1101A_STARTLINE(ln) (0x40 | ((ln) & 0x3f)) /* Set Display Start Line: (40h - 7fh) */
  141. #define SH1101A_CONTRAST_MODE (0x81) /* Set Contrast Control Register: (Double Bytes Command) */
  142. # define SH1101A_CONTRAST(c) (c)
  143. #define SH1101A_SEGREMAP(m) (0xa0 | ((m) & 0x01)) /* Set Segment Re-map: (a0h - a1h) */
  144. # define SH1101A_REMAPRIGHT SH1101A_SEGREMAP(0) /* Right rotation */
  145. # define SH1101A_REMAPPLEFT SH1101A_SEGREMAP(1) /* Left rotation */
  146. #define SH1101A_EDISPOFFON(s) (0xa4 | ((s) & 0x01)) /* Set Entire Display OFF/ON: (a4h - a5h) */
  147. # define SH1101A_EDISPOFF SH1101A_EDISPOFFON(0) /* Display off */
  148. # define SH1101A_EDISPON SH1101A_EDISPOFFON(1) /* Display on */
  149. #define SH1101A_NORMREV(s) (0xa6 | ((s) & 0x01)) /* Set Normal/Reverse Display: (a6h -a7h) */
  150. # define SH1101A_NORMAL SH1101A_NORMREV(0) /* Normal display */
  151. # define SH1101A_REVERSE SH1101A_NORMREV(1) /* Reverse display */
  152. #define SH1101A_MRATIO_MODE (0xa8) /* Set Multiplex Ration: (Double Bytes Command) */
  153. # define SH1101A_MRATIO(d) ((d) & 0x3f)
  154. #define SH1101A_DCDC_MODE (0xad) /* Set DC-DC OFF/ON: (Double Bytes Command) */
  155. # define SH1101A_DCDC_OFF (0x8a)
  156. # define SH1101A_DCDC_ON (0x8b)
  157. #define SH1101A_DISPOFFON(s) (0xae | ((s) & 0x01)) /* Display OFF/ON: (aeh - afh) */
  158. # define SH1101A_DISPOFF SH1101A_DISPOFFON(0) /* Display off */
  159. # define SH1101A_DISPON SH1101A_DISPOFFON(1) /* Display on */
  160. #define SH1101A_PAGEADDR(a) (0xb0 | ((a) & 0x0f)) /* Set Page Address: (b0h - b7h) */
  161. #define SH1101A_SCANDIR(d) (0xc0 | ((d) & 0x08)) /* Set Common Output Scan Direction: (c0h - c8h) */
  162. # define SH1101A_SCANFROMCOM0 SH1101A_SCANDIR(0x00) /* Scan from COM[0] to COM[n-1]*/
  163. # define SH1101A_SCANTOCOM0 SH1101A_SCANDIR(0x08) /* Scan from COM[n-1] to COM[0] */
  164. #define SH1101A_DISPOFFS_MODE (0xd3) /* Set Display Offset: (Double Bytes Command) */
  165. # define SH1101A_DISPOFFS(o) ((o) & 0x3f)
  166. #define SH1101A_CLKDIV_SET (0xd5) /* Set Display Clock Divide Ratio/Oscillator Frequency: (Double Bytes Command) */
  167. # define SH1101A_CLKDIV(f,d) ((((f) & 0x0f) << 4) | ((d) & 0x0f))
  168. #define SH1101A_CHRGPER_SET (0xd9) /* Set Dis-charge/Pre-charge Period: (Double Bytes Command) */
  169. # define SH1101A_CHRGPER(d,p) ((((d) & 0x0f) << 4) | ((p) & 0x0f))
  170. #define SH1101A_CMNPAD_CONFIG (0xda) /* Set Common pads hardware configuration: (Double Bytes Command) */
  171. #define SH1101A_CMNPAD(c) ((0x02) | ((c) & 0x10))
  172. #define SH1101A_VCOM_SET (0xdb) /* Set VCOM Deselect Level: (Double Bytes Command) */
  173. # define SH1101A_VCOM(v) (v)
  174. #define SH1101A_RMWSTART (0xe0) /* Read-Modify-Write: (e0h) */
  175. #define SH1101A_NOP (0xe3) /* NOP: (e3h) */
  176. #define SH1101A_END (0xee) /* End: (eeh) */
  177. #define SH1101A_WRDATA(d) (d) /* Write Display Data */
  178. #define SH1101A_STATUS_BUSY (0x80) /* Read Status */
  179. #define SH1101A_STATUS_ONOFF (0x40)
  180. #define SH1101A_RDDATA(d) (d) /* Read Display Data */
  181. /* Color Properties *********************************************************/
  182. /* Display Resolution
  183. *
  184. * The SH1101A display controller can handle a resolution of 132x64.
  185. * The UG-2864AMBAG01 on the base board is 128x64.
  186. */
  187. #define UG2864AMBAG01_DEV_XRES 128 /* Only 128 of 131 columns used */
  188. #define UG2864AMBAG01_DEV_YRES 64 /* 8 pages each 8 rows */
  189. #define UG2864AMBAG01_DEV_XOFFSET 2 /* Offset to logical column 0 */
  190. #define UG2864AMBAG01_DEV_PAGES 8 /* 8 pages */
  191. #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE)
  192. # define UG2864AMBAG01_XRES UG2864AMBAG01_DEV_XRES
  193. # define UG2864AMBAG01_YRES UG2864AMBAG01_DEV_YRES
  194. #else
  195. # define UG2864AMBAG01_XRES UG2864AMBAG01_DEV_YRES
  196. # define UG2864AMBAG01_YRES UG2864AMBAG01_DEV_XRES
  197. #endif
  198. /* Color depth and format */
  199. #define UG2864AMBAG01_BPP 1
  200. #define UG2864AMBAG01_COLORFMT FB_FMT_Y1
  201. /* Bytes per logical row and actual device row */
  202. #define UG2864AMBAG01_XSTRIDE (UG2864AMBAG01_XRES >> 3)
  203. #define UG2864AMBAG01_YSTRIDE (UG2864AMBAG01_YRES >> 3)
  204. /* Default contrast */
  205. #define UG2864AMBAG01_CONTRAST (128)
  206. /* The size of the shadow frame buffer or one row buffer.
  207. *
  208. * Frame buffer size: 128 columns x 64 rows / 8 bits-per-pixel
  209. * Row size: 128 columns x 8 rows-per-page / 8 bits-per-pixel
  210. */
  211. #define UG2864AMBAG01_FBSIZE (UG2864AMBAG01_XSTRIDE * UG2864AMBAG01_YRES)
  212. #define UG2864AMBAG01_ROWSIZE (UG2864AMBAG01_XSTRIDE)
  213. /* Orientation */
  214. #if defined(CONFIG_LCD_LANDSCAPE)
  215. # undef UG2864AMBAG01_DEV_REVERSEX
  216. # undef UG2864AMBAG01_DEV_REVERSEY
  217. #elif defined(CONFIG_LCD_RLANDSCAPE)
  218. # define UG2864AMBAG01_DEV_REVERSEX 1
  219. # define UG2864AMBAG01_DEV_REVERSEY 1
  220. #endif
  221. /* Bit helpers */
  222. #define LS_BIT (1 << 0)
  223. #define MS_BIT (1 << 7)
  224. /****************************************************************************
  225. * Private Type Definition
  226. ****************************************************************************/
  227. /* This structure describes the state of this driver */
  228. struct ug2864ambag01_dev_s
  229. {
  230. struct lcd_dev_s dev; /* Publicly visible device structure */
  231. /* Private LCD-specific information follows */
  232. FAR struct spi_dev_s *spi; /* Cached SPI device reference */
  233. uint8_t contrast; /* Current contrast setting */
  234. bool on; /* true: display is on */
  235. /* The SH1101A does not support reading from the display memory in SPI
  236. * mode. Since there is 1 BPP and access is byte-by-byte, it is necessary
  237. * to keep a shadow copy of the framebuffer memory. At 128x64, this amounts
  238. * to 1KB.
  239. */
  240. uint8_t fb[UG2864AMBAG01_FBSIZE];
  241. };
  242. /****************************************************************************
  243. * Private Function Protototypes
  244. ****************************************************************************/
  245. /* Low-level SPI helpers */
  246. static void ug2864ambag01_lock(FAR struct spi_dev_s *spi);
  247. static void ug2864ambag01_unlock(FAR struct spi_dev_s *spi);
  248. /* LCD Data Transfer Methods */
  249. static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col,
  250. FAR const uint8_t *buffer, size_t npixels);
  251. static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col,
  252. FAR uint8_t *buffer,
  253. size_t npixels);
  254. /* LCD Configuration */
  255. static int ug2864ambag01_getvideoinfo(FAR struct lcd_dev_s *dev,
  256. FAR struct fb_videoinfo_s *vinfo);
  257. static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev,
  258. unsigned int planeno,
  259. FAR struct lcd_planeinfo_s *pinfo);
  260. /* LCD RGB Mapping */
  261. #ifdef CONFIG_FB_CMAP
  262. # error "RGB color mapping not supported by this driver"
  263. #endif
  264. /* Cursor Controls */
  265. #ifdef CONFIG_FB_HWCURSOR
  266. # error "Cursor control not supported by this driver"
  267. #endif
  268. /* LCD Specific Controls */
  269. static int ug2864ambag01_getpower(struct lcd_dev_s *dev);
  270. static int ug2864ambag01_setpower(struct lcd_dev_s *dev, int power);
  271. static int ug2864ambag01_getcontrast(struct lcd_dev_s *dev);
  272. static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev,
  273. unsigned int contrast);
  274. /****************************************************************************
  275. * Private Data
  276. ****************************************************************************/
  277. /* This is working memory allocated by the LCD driver for each LCD device
  278. * and for each color plane. This memory will hold one raster line of data.
  279. * The size of the allocated run buffer must therefore be at least
  280. * (bpp * xres / 8). Actual alignment of the buffer must conform to the
  281. * bitwidth of the underlying pixel type.
  282. *
  283. * If there are multiple planes, they may share the same working buffer
  284. * because different planes will not be operate on concurrently. However,
  285. * if there are multiple LCD devices, they must each have unique run buffers.
  286. */
  287. static uint8_t g_runbuffer[UG2864AMBAG01_ROWSIZE];
  288. /* This structure describes the overall LCD video controller */
  289. static const struct fb_videoinfo_s g_videoinfo =
  290. {
  291. .fmt = UG2864AMBAG01_COLORFMT, /* Color format: RGB16-565: RRRR RGGG GGGB BBBB */
  292. .xres = UG2864AMBAG01_XRES, /* Horizontal resolution in pixel columns */
  293. .yres = UG2864AMBAG01_YRES, /* Vertical resolution in pixel rows */
  294. .nplanes = 1, /* Number of color planes supported */
  295. };
  296. /* This is the standard, NuttX Plane information object */
  297. static const struct lcd_planeinfo_s g_planeinfo =
  298. {
  299. .putrun = ug2864ambag01_putrun, /* Put a run into LCD memory */
  300. .getrun = ug2864ambag01_getrun, /* Get a run from LCD memory */
  301. .buffer = (FAR uint8_t *)g_runbuffer, /* Run scratch buffer */
  302. .bpp = UG2864AMBAG01_BPP, /* Bits-per-pixel */
  303. };
  304. /* This is the OLED driver instance
  305. * (only a single device is supported for now)
  306. */
  307. static struct ug2864ambag01_dev_s g_oleddev =
  308. {
  309. .dev =
  310. {
  311. /* LCD Configuration */
  312. .getvideoinfo = ug2864ambag01_getvideoinfo,
  313. .getplaneinfo = ug2864ambag01_getplaneinfo,
  314. /* LCD RGB Mapping -- Not supported */
  315. /* Cursor Controls -- Not supported */
  316. /* LCD Specific Controls */
  317. .getpower = ug2864ambag01_getpower,
  318. .setpower = ug2864ambag01_setpower,
  319. .getcontrast = ug2864ambag01_getcontrast,
  320. .setcontrast = ug2864ambag01_setcontrast,
  321. },
  322. };
  323. /****************************************************************************
  324. * Private Functions
  325. ****************************************************************************/
  326. /****************************************************************************
  327. * Name: ug2864ambag01_lock
  328. *
  329. * Description:
  330. * Select the SPI, locking and re-configuring if necessary
  331. *
  332. * Input Parameters:
  333. * spi - Reference to the SPI driver structure
  334. *
  335. * Returned Value:
  336. * None
  337. *
  338. * Assumptions:
  339. *
  340. ****************************************************************************/
  341. static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi)
  342. {
  343. /* Lock the SPI bus if there are multiple devices competing for the SPI
  344. * bus.
  345. */
  346. SPI_LOCK(spi, true);
  347. /* Now make sure that the SPI bus is configured for the UG-2864AMBAG01 (it
  348. * might have gotten configured for a different device while unlocked)
  349. */
  350. SPI_SETMODE(spi, CONFIG_UG2864AMBAG01_SPIMODE);
  351. SPI_SETBITS(spi, 8);
  352. SPI_HWFEATURES(spi, 0);
  353. SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY);
  354. }
  355. /****************************************************************************
  356. * Name: ug2864ambag01_unlock
  357. *
  358. * Description:
  359. * De-select the SPI
  360. *
  361. * Input Parameters:
  362. * spi - Reference to the SPI driver structure
  363. *
  364. * Returned Value:
  365. * None
  366. *
  367. * Assumptions:
  368. *
  369. ****************************************************************************/
  370. static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi)
  371. {
  372. /* De-select UG-2864AMBAG01 chip and relinquish the SPI bus. */
  373. SPI_LOCK(spi, false);
  374. }
  375. /****************************************************************************
  376. * Name: ug2864ambag01_putrun
  377. *
  378. * Description:
  379. * This method can be used to write a partial raster line to the LCD.
  380. *
  381. * Input Parameters:
  382. * row - Starting row to write to (range: 0 <= row < yres)
  383. * col - Starting column to write to (range: 0 <= col <= xres-npixels)
  384. * buffer - The buffer containing the run to be written to the LCD
  385. * npixels - The number of pixels to write to the LCD
  386. * (range: 0 < npixels <= xres-col)
  387. *
  388. ****************************************************************************/
  389. #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE)
  390. static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col,
  391. FAR const uint8_t *buffer,
  392. size_t npixels)
  393. {
  394. /* Because of this line of code, we will only be able to support a single
  395. * UG device
  396. */
  397. FAR struct ug2864ambag01_dev_s *priv =
  398. (FAR struct ug2864ambag01_dev_s *)&g_oleddev;
  399. FAR uint8_t *fbptr;
  400. FAR uint8_t *ptr;
  401. uint8_t devcol;
  402. uint8_t fbmask;
  403. uint8_t page;
  404. uint8_t usrmask;
  405. int pixlen;
  406. uint8_t i;
  407. lcdinfo("row: %d col: %d npixels: %d\n", row, col, npixels);
  408. DEBUGASSERT(buffer);
  409. /* Clip the run to the display */
  410. pixlen = npixels;
  411. if ((unsigned int)col + (unsigned int)pixlen >
  412. (unsigned int)UG2864AMBAG01_XRES)
  413. {
  414. pixlen = (int)UG2864AMBAG01_XRES - (int)col;
  415. }
  416. /* Verify that some portion of the run remains on the display */
  417. if (pixlen <= 0 || row > UG2864AMBAG01_YRES)
  418. {
  419. return OK;
  420. }
  421. /* Perform coordinate conversion for reverse landscape mode.
  422. * If the rows are reversed then rows are are a mirror reflection of
  423. * top to bottom.
  424. */
  425. #ifdef UG2864AMBAG01_DEV_REVERSEY
  426. row = (UG2864AMBAG01_DEV_YRES - 1) - row;
  427. #endif
  428. /* If the column is switched then the start of the run is the mirror of
  429. * the end of the run.
  430. *
  431. * col+pixlen-1
  432. * col |
  433. * 0 | | XRES
  434. * . S>>>>>>E .
  435. * . E<<<<<<S .
  436. * | |
  437. * | `-(XRES-1)-col
  438. * ` (XRES-1)-col-(pixlen-1)
  439. */
  440. #ifdef UG2864AMBAG01_DEV_REVERSEX
  441. col = (UG2864AMBAG01_DEV_XRES - 1) - col;
  442. col -= (pixlen - 1);
  443. #endif
  444. /* Get the page number. The range of 64 lines is divided up into eight
  445. * pages of 8 lines each.
  446. */
  447. page = row >> 3;
  448. /* Update the shadow frame buffer memory. First determine the pixel
  449. * position in the frame buffer memory. Pixels are organized like
  450. * this:
  451. *
  452. * --------+---+---+---+---+-...-+-----+
  453. * Segment | 0 | 1 | 2 | 3 | ... | 131 |
  454. * --------+---+---+---+---+-...-+-----+
  455. * D0 | | X | | | | |
  456. * D1 | | X | | | | |
  457. * D2 | | X | | | | |
  458. * D3 | | X | | | | |
  459. * D4 | | X | | | | |
  460. * D5 | | X | | | | |
  461. * D6 | | X | | | | |
  462. * D7 | | X | | | | |
  463. * --------+---+---+---+---+-...-+-----+
  464. *
  465. * So, in order to draw a white, horizontal line, at row 45. we
  466. * would have to modify all of the bytes in page 45/8 = 5. We
  467. * would have to set bit 45%8 = 5 in every byte in the page.
  468. */
  469. fbmask = 1 << (row & 7);
  470. fbptr = &priv->fb[page * UG2864AMBAG01_XRES + col];
  471. #ifdef UG2864AMBAG01_DEV_REVERSEX
  472. ptr = fbptr + (pixlen - 1);
  473. #else
  474. ptr = fbptr;
  475. #endif
  476. #ifdef CONFIG_LCD_PACKEDMSFIRST
  477. usrmask = MS_BIT;
  478. #else
  479. usrmask = LS_BIT;
  480. #endif
  481. for (i = 0; i < pixlen; i++)
  482. {
  483. /* Set or clear the corresponding bit */
  484. #ifdef UG2864AMBAG01_DEV_REVERSEX
  485. if ((*buffer & usrmask) != 0)
  486. {
  487. *ptr-- |= fbmask;
  488. }
  489. else
  490. {
  491. *ptr-- &= ~fbmask;
  492. }
  493. #else
  494. if ((*buffer & usrmask) != 0)
  495. {
  496. *ptr++ |= fbmask;
  497. }
  498. else
  499. {
  500. *ptr++ &= ~fbmask;
  501. }
  502. #endif
  503. /* Inc/Decrement to the next source pixel */
  504. #ifdef CONFIG_LCD_PACKEDMSFIRST
  505. if (usrmask == LS_BIT)
  506. {
  507. buffer++;
  508. usrmask = MS_BIT;
  509. }
  510. else
  511. {
  512. usrmask >>= 1;
  513. }
  514. #else
  515. if (usrmask == MS_BIT)
  516. {
  517. buffer++;
  518. usrmask = LS_BIT;
  519. }
  520. else
  521. {
  522. usrmask <<= 1;
  523. }
  524. #endif
  525. }
  526. /* Offset the column position to account for smaller horizontal
  527. * display range.
  528. */
  529. devcol = col + UG2864AMBAG01_DEV_XOFFSET;
  530. /* Lock and select device */
  531. ug2864ambag01_lock(priv->spi);
  532. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true);
  533. /* Select command transfer */
  534. SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), true);
  535. /* Set the starting position for the run */
  536. /* Set the column address to the XOFFSET value */
  537. SPI_SEND(priv->spi, SH1101A_SETCOLL(devcol & 0x0f));
  538. SPI_SEND(priv->spi, SH1101A_SETCOLH(devcol >> 4));
  539. /* Set the page address */
  540. SPI_SEND(priv->spi, SH1101A_PAGEADDR(page));
  541. /* Select data transfer */
  542. SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), false);
  543. /* Then transfer all of the data */
  544. SPI_SNDBLOCK(priv->spi, fbptr, pixlen);
  545. /* De-select and unlock the device */
  546. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false);
  547. ug2864ambag01_unlock(priv->spi);
  548. return OK;
  549. }
  550. #else
  551. # error "Configuration not implemented"
  552. #endif
  553. /****************************************************************************
  554. * Name: ug2864ambag01_getrun
  555. *
  556. * Description:
  557. * This method can be used to read a partial raster line from the LCD.
  558. *
  559. * Description:
  560. * This method can be used to write a partial raster line to the LCD.
  561. *
  562. * row - Starting row to read from (range: 0 <= row < yres)
  563. * col - Starting column to read read (range: 0 <= col <= xres-npixels)
  564. * buffer - The buffer in which to return the run read from the LCD
  565. * npixels - The number of pixels to read from the LCD
  566. * (range: 0 < npixels <= xres-col)
  567. *
  568. ****************************************************************************/
  569. #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE)
  570. static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col,
  571. FAR uint8_t *buffer,
  572. size_t npixels)
  573. {
  574. /* Because of this line of code, we will only be able to support a single
  575. * UG device
  576. */
  577. FAR struct ug2864ambag01_dev_s *priv = &g_oleddev;
  578. FAR uint8_t *fbptr;
  579. uint8_t page;
  580. uint8_t fbmask;
  581. uint8_t usrmask;
  582. int pixlen;
  583. uint8_t i;
  584. lcdinfo("row: %d col: %d npixels: %d\n", row, col, npixels);
  585. DEBUGASSERT(buffer);
  586. /* Clip the run to the display */
  587. pixlen = npixels;
  588. if ((unsigned int)col + (unsigned int)pixlen >
  589. (unsigned int)UG2864AMBAG01_XRES)
  590. {
  591. pixlen = (int)UG2864AMBAG01_XRES - (int)col;
  592. }
  593. /* Verify that some portion of the run is actually the display */
  594. if (pixlen <= 0 || row > UG2864AMBAG01_YRES)
  595. {
  596. return -EINVAL;
  597. }
  598. /* Perform coordinate conversion for reverse landscape mode.
  599. * If the rows are reversed then rows are are a mirror reflection of
  600. * top to bottom.
  601. */
  602. #ifdef UG2864AMBAG01_DEV_REVERSEY
  603. row = (UG2864AMBAG01_DEV_YRES - 1) - row;
  604. #endif
  605. /* If the column is switched then the start of the run is the mirror of
  606. * the end of the run.
  607. *
  608. * col+pixlen-1
  609. * col |
  610. * 0 | | XRES
  611. * . S>>>>>>E .
  612. * . E<<<<<<S .
  613. * | |
  614. * | `-(XRES-1)-col
  615. * ` (XRES-1)-col-(pixlen-1)
  616. */
  617. #ifdef UG2864AMBAG01_DEV_REVERSEX
  618. col = (UG2864AMBAG01_DEV_XRES - 1) - col;
  619. #endif
  620. /* Then transfer the display data from the shadow frame buffer memory */
  621. /* Get the page number. The range of 64 lines is divided up into eight
  622. * pages of 8 lines each.
  623. */
  624. page = row >> 3;
  625. /* Update the shadow frame buffer memory. First determine the pixel
  626. * position in the frame buffer memory. Pixels are organized like
  627. * this:
  628. *
  629. * --------+---+---+---+---+-...-+-----+
  630. * Segment | 0 | 1 | 2 | 3 | ... | 131 |
  631. * --------+---+---+---+---+-...-+-----+
  632. * D0 | | X | | | | |
  633. * D1 | | X | | | | |
  634. * D2 | | X | | | | |
  635. * D3 | | X | | | | |
  636. * D4 | | X | | | | |
  637. * D5 | | X | | | | |
  638. * D6 | | X | | | | |
  639. * D7 | | X | | | | |
  640. * --------+---+---+---+---+-...-+-----+
  641. *
  642. * So, in order to draw a white, horizontal line, at row 45. we
  643. * would have to modify all of the bytes in page 45/8 = 5. We
  644. * would have to set bit 45%8 = 5 in every byte in the page.
  645. */
  646. fbmask = 1 << (row & 7);
  647. fbptr = &priv->fb[page * UG2864AMBAG01_XRES + col];
  648. #ifdef CONFIG_LCD_PACKEDMSFIRST
  649. usrmask = MS_BIT;
  650. #else
  651. usrmask = LS_BIT;
  652. #endif
  653. *buffer = 0;
  654. for (i = 0; i < pixlen; i++)
  655. {
  656. /* Set or clear the corresponding bit */
  657. #ifdef UG2864AMBAG01_DEV_REVERSEX
  658. uint8_t byte = *fbptr--;
  659. #else
  660. uint8_t byte = *fbptr++;
  661. #endif
  662. if ((byte & fbmask) != 0)
  663. {
  664. *buffer |= usrmask;
  665. }
  666. /* Inc/Decrement to the next destination pixel. Hmmmm. It looks like
  667. * this logic could write past the end of the user buffer. Revisit
  668. * this!
  669. */
  670. #ifdef CONFIG_LCD_PACKEDMSFIRST
  671. if (usrmask == LS_BIT)
  672. {
  673. buffer++;
  674. *buffer = 0;
  675. usrmask = MS_BIT;
  676. }
  677. else
  678. {
  679. usrmask >>= 1;
  680. }
  681. #else
  682. if (usrmask == MS_BIT)
  683. {
  684. buffer++;
  685. *buffer = 0;
  686. usrmask = LS_BIT;
  687. }
  688. else
  689. {
  690. usrmask <<= 1;
  691. }
  692. #endif
  693. }
  694. return OK;
  695. }
  696. #else
  697. # error "Configuration not implemented"
  698. #endif
  699. /****************************************************************************
  700. * Name: ug2864ambag01_getvideoinfo
  701. *
  702. * Description:
  703. * Get information about the LCD video controller configuration.
  704. *
  705. ****************************************************************************/
  706. static int ug2864ambag01_getvideoinfo(FAR struct lcd_dev_s *dev,
  707. FAR struct fb_videoinfo_s *vinfo)
  708. {
  709. DEBUGASSERT(dev && vinfo);
  710. lcdinfo("fmt: %d xres: %d yres: %d nplanes: %d\n",
  711. g_videoinfo.fmt, g_videoinfo.xres,
  712. g_videoinfo.yres, g_videoinfo.nplanes);
  713. memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s));
  714. return OK;
  715. }
  716. /****************************************************************************
  717. * Name: ug2864ambag01_getplaneinfo
  718. *
  719. * Description:
  720. * Get information about the configuration of each LCD color plane.
  721. *
  722. ****************************************************************************/
  723. static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev,
  724. unsigned int planeno,
  725. FAR struct lcd_planeinfo_s *pinfo)
  726. {
  727. DEBUGASSERT(pinfo && planeno == 0);
  728. lcdinfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp);
  729. memcpy(pinfo, &g_planeinfo, sizeof(struct lcd_planeinfo_s));
  730. return OK;
  731. }
  732. /****************************************************************************
  733. * Name: ug2864ambag01_getpower
  734. *
  735. * Description:
  736. * Get the LCD panel power status
  737. * (0: full off - CONFIG_LCD_MAXPOWER: full on.)
  738. * On backlit LCDs, this setting may correspond to the backlight setting.
  739. *
  740. ****************************************************************************/
  741. static int ug2864ambag01_getpower(FAR struct lcd_dev_s *dev)
  742. {
  743. FAR struct ug2864ambag01_dev_s *priv =
  744. (FAR struct ug2864ambag01_dev_s *)dev;
  745. DEBUGASSERT(priv);
  746. lcdinfo("power: %s\n", priv->on ? "ON" : "OFF");
  747. return priv->on ? CONFIG_LCD_MAXPOWER : 0;
  748. }
  749. /****************************************************************************
  750. * Name: ug2864ambag01_setpower
  751. *
  752. * Description:
  753. * Enable/disable LCD panel power
  754. * (0: full off - CONFIG_LCD_MAXPOWER: full on). On
  755. * backlit LCDs, this setting may correspond to the backlight setting.
  756. *
  757. ****************************************************************************/
  758. static int ug2864ambag01_setpower(struct lcd_dev_s *dev, int power)
  759. {
  760. struct ug2864ambag01_dev_s *priv = (struct ug2864ambag01_dev_s *)dev;
  761. DEBUGASSERT(priv && (unsigned)power <= CONFIG_LCD_MAXPOWER && priv->spi);
  762. lcdinfo("power: %d [%d]\n", power, priv->on ? CONFIG_LCD_MAXPOWER : 0);
  763. /* Lock and select device */
  764. ug2864ambag01_lock(priv->spi);
  765. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true);
  766. if (power <= 0)
  767. {
  768. /* Turn the display off */
  769. SPI_SEND(priv->spi, SH1101A_DISPOFF);
  770. priv->on = false;
  771. }
  772. else
  773. {
  774. /* Turn the display on */
  775. SPI_SEND(priv->spi, SH1101A_DISPON);
  776. priv->on = true;
  777. }
  778. /* De-select and unlock the device */
  779. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false);
  780. ug2864ambag01_unlock(priv->spi);
  781. return OK;
  782. }
  783. /****************************************************************************
  784. * Name: ug2864ambag01_getcontrast
  785. *
  786. * Description:
  787. * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST).
  788. *
  789. ****************************************************************************/
  790. static int ug2864ambag01_getcontrast(struct lcd_dev_s *dev)
  791. {
  792. struct ug2864ambag01_dev_s *priv = (struct ug2864ambag01_dev_s *)dev;
  793. DEBUGASSERT(priv);
  794. lcdinfo("contrast: %d\n", priv->contrast);
  795. return priv->contrast;
  796. }
  797. /****************************************************************************
  798. * Name: ug2864ambag01_setcontrast
  799. *
  800. * Description:
  801. * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST).
  802. *
  803. ****************************************************************************/
  804. static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev,
  805. unsigned int contrast)
  806. {
  807. struct ug2864ambag01_dev_s *priv = (struct ug2864ambag01_dev_s *)dev;
  808. unsigned int scaled;
  809. lcdinfo("contrast: %d\n", contrast);
  810. DEBUGASSERT(priv);
  811. /* Verify the contrast value */
  812. #ifdef CONFIG_DEBUG_FEATURES
  813. if (contrast > CONFIG_LCD_MAXCONTRAST)
  814. {
  815. return -EINVAL;
  816. }
  817. #endif
  818. /* Scale contrast: newcontrast = 255 * contrast / CONFIG_LCD_MAXCONTRAST
  819. * Where contrast is in the range {1,255}
  820. */
  821. #if CONFIG_LCD_MAXCONTRAST != 255
  822. scaled = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST;
  823. #else
  824. scaled = contrast;
  825. #endif
  826. /* Lock and select device */
  827. ug2864ambag01_lock(priv->spi);
  828. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true);
  829. /* Select command transfer */
  830. SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), true);
  831. /* Set the contrast */
  832. SPI_SEND(priv->spi, SH1101A_CONTRAST_MODE); /* Set contrast control register */
  833. SPI_SEND(priv->spi, SH1101A_CONTRAST(scaled)); /* Data 1: Set 1 of 256 contrast steps */
  834. priv->contrast = contrast;
  835. /* De-select and unlock the device */
  836. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false);
  837. ug2864ambag01_unlock(priv->spi);
  838. return OK;
  839. }
  840. /****************************************************************************
  841. * Public Functions
  842. ****************************************************************************/
  843. /****************************************************************************
  844. * Name: ug2864ambag01_initialize
  845. *
  846. * Description:
  847. * Initialize the UG-2864AMBAG01 video hardware. The initial state of the
  848. * OLED is fully initialized, display memory cleared, and the OLED ready
  849. * to use, but with the power setting at 0 (full off == sleep mode).
  850. *
  851. * Input Parameters:
  852. *
  853. * spi - A reference to the SPI driver instance.
  854. * devno - A value in the range of 0 through
  855. * CONFIG_UG2864AMBAG01_NINTERFACES-1.
  856. * This allows support for multiple OLED devices.
  857. *
  858. * Returned Value:
  859. *
  860. * On success, this function returns a reference to the LCD object for
  861. * the specified OLED. NULL is returned on any failure.
  862. *
  863. ****************************************************************************/
  864. FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi,
  865. unsigned int devno)
  866. {
  867. FAR struct ug2864ambag01_dev_s *priv = &g_oleddev;
  868. lcdinfo("Initializing\n");
  869. DEBUGASSERT(spi && devno == 0);
  870. /* Save the reference to the SPI device */
  871. priv->spi = spi;
  872. /* Lock and select device */
  873. ug2864ambag01_lock(priv->spi);
  874. SPI_SELECT(spi, SPIDEV_DISPLAY(0), true);
  875. /* Select command transfer */
  876. SPI_CMDDATA(spi, SPIDEV_DISPLAY(0), true);
  877. /* Configure the device */
  878. SPI_SEND(spi, SH1101A_DISPOFF); /* Display off */
  879. SPI_SEND(spi, SH1101A_SETCOLL(0)); /* Set lower column address */
  880. SPI_SEND(spi, SH1101A_SETCOLH(0)); /* Set higher column address */
  881. SPI_SEND(spi, SH1101A_STARTLINE(0)); /* Set display start line */
  882. SPI_SEND(spi, SH1101A_PAGEADDR(0)); /* Set page address */
  883. SPI_SEND(spi, SH1101A_CONTRAST_MODE); /* Contrast control */
  884. SPI_SEND(spi, UG2864AMBAG01_CONTRAST); /* Default contrast */
  885. SPI_SEND(spi, SH1101A_REMAPPLEFT); /* Set segment remap left */
  886. SPI_SEND(spi, SH1101A_EDISPOFF); /* Normal display */
  887. SPI_SEND(spi, SH1101A_NORMAL); /* Normal (un-reversed) display mode */
  888. SPI_SEND(spi, SH1101A_MRATIO_MODE); /* Multiplex ratio */
  889. SPI_SEND(spi, SH1101A_MRATIO(0x3f)); /* Duty = 1/64 */
  890. SPI_SEND(spi, SH1101A_SCANTOCOM0); /* Com scan direction: Scan from COM[n-1] to COM[0] */
  891. SPI_SEND(spi, SH1101A_DISPOFFS_MODE); /* Set display offset */
  892. SPI_SEND(spi, SH1101A_DISPOFFS(0));
  893. SPI_SEND(spi, SH1101A_CLKDIV_SET); /* Set clock divider */
  894. SPI_SEND(spi, SH1101A_CLKDIV(0, 0));
  895. SPI_SEND(spi, SH1101A_CMNPAD_CONFIG); /* Set common pads */
  896. SPI_SEND(spi, SH1101A_CMNPAD(0x10));
  897. SPI_SEND(spi, SH1101A_VCOM_SET);
  898. SPI_SEND(spi, SH1101A_VCOM(0x40));
  899. SPI_SEND(spi, SH1101A_DCDC_MODE); /* DC/DC control mode: on */
  900. SPI_SEND(spi, SH1101A_DCDC_ON);
  901. SPI_SEND(spi, SH1101A_DISPON); /* display ON */
  902. /* De-select and unlock the device */
  903. SPI_SELECT(spi, SPIDEV_DISPLAY(0), false);
  904. ug2864ambag01_unlock(priv->spi);
  905. /* Clear the display */
  906. up_mdelay(100);
  907. ug2864ambag01_fill(&priv->dev, UG_Y1_BLACK);
  908. return &priv->dev;
  909. }
  910. /****************************************************************************
  911. * Name: ug2864ambag01_fill
  912. *
  913. * Description:
  914. * This non-standard method can be used to clear the entire display by
  915. * writing one color to the display.
  916. * This is much faster than writing a series of runs.
  917. *
  918. * Input Parameters:
  919. * priv - Reference to private driver structure
  920. *
  921. * Assumptions:
  922. * Caller has selected the OLED section.
  923. *
  924. ****************************************************************************/
  925. void ug2864ambag01_fill(FAR struct lcd_dev_s *dev, uint8_t color)
  926. {
  927. FAR struct ug2864ambag01_dev_s *priv = &g_oleddev;
  928. unsigned int page;
  929. /* Make an 8-bit version of the selected color */
  930. if (color & 1)
  931. {
  932. color = 0xff;
  933. }
  934. else
  935. {
  936. color = 0;
  937. }
  938. /* Initialize the framebuffer */
  939. memset(priv->fb, color, UG2864AMBAG01_FBSIZE);
  940. /* Lock and select device */
  941. ug2864ambag01_lock(priv->spi);
  942. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true);
  943. /* Visit each page */
  944. for (page = 0; page < UG2864AMBAG01_DEV_PAGES; page++)
  945. {
  946. /* Select command transfer */
  947. SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), true);
  948. /* Set the column address to the XOFFSET value */
  949. SPI_SEND(priv->spi, SH1101A_SETCOLL(UG2864AMBAG01_DEV_XOFFSET));
  950. SPI_SEND(priv->spi, SH1101A_SETCOLH(0));
  951. /* Set the page address */
  952. SPI_SEND(priv->spi, SH1101A_PAGEADDR(page));
  953. /* Select data transfer */
  954. SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), false);
  955. /* Transfer one page of the selected color */
  956. SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG2864AMBAG01_XRES],
  957. UG2864AMBAG01_XRES);
  958. }
  959. /* De-select and unlock the device */
  960. SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false);
  961. ug2864ambag01_unlock(priv->spi);
  962. }
  963. #endif /* CONFIG_LCD_UG2864AMBAG01 */