Guest User

Untitled

a guest
Jul 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.37 KB | None | 0 0
  1. Index: firmware/export/config/sansafuze.h
  2. ===================================================================
  3. --- firmware/export/config/sansafuze.h (revision 24186)
  4. +++ firmware/export/config/sansafuze.h (working copy)
  5. @@ -204,3 +204,4 @@
  6.  
  7. #define INCLUDE_TIMEOUT_API
  8.  
  9. +#define DBOP_PRECHARGE 0x80FF
  10. Index: firmware/export/config/sansac200v2.h
  11. ===================================================================
  12. --- firmware/export/config/sansac200v2.h (revision 24186)
  13. +++ firmware/export/config/sansac200v2.h (working copy)
  14. @@ -197,3 +197,5 @@
  15. #define DEFAULT_REC_MIC_GAIN 23
  16. #define DEFAULT_REC_LEFT_GAIN 23
  17. #define DEFAULT_REC_RIGHT_GAIN 23
  18. +
  19. +#define DBOP_PRECHARGE 0xF0FF
  20. Index: firmware/export/config/sansae200v2.h
  21. ===================================================================
  22. --- firmware/export/config/sansae200v2.h (revision 24186)
  23. +++ firmware/export/config/sansae200v2.h (working copy)
  24. @@ -210,3 +210,5 @@
  25. #define DEFAULT_REC_MIC_GAIN 23
  26. #define DEFAULT_REC_LEFT_GAIN 23
  27. #define DEFAULT_REC_RIGHT_GAIN 23
  28. +
  29. +#define DBOP_PRECHARGE 0xF0FF
  30. Index: firmware/SOURCES
  31. ===================================================================
  32. --- firmware/SOURCES (revision 24186)
  33. +++ firmware/SOURCES (working copy)
  34. @@ -1235,6 +1235,7 @@
  35. target/arm/as3525/lcd-as-e200v2-fuze.S
  36. target/arm/as3525/button-e200v2-fuze.c
  37. target/arm/as3525/backlight-e200v2-fuze.c
  38. +target/arm/as3525/dbop-as3525.c
  39. #ifndef BOOTLOADER
  40. target/arm/powermgmt-ascodec.c
  41. target/arm/as3525/sansa-e200v2/powermgmt-e200v2.c
  42. @@ -1247,6 +1248,7 @@
  43. target/arm/lcd-c200_c200v2.c
  44. target/arm/as3525/sansa-c200v2/button-c200v2.c
  45. target/arm/as3525/sansa-c200v2/backlight-c200v2.c
  46. +target/arm/as3525/dbop-as3525.c
  47. #ifndef BOOTLOADER
  48. target/arm/as3525/powermgmt-as3525.c
  49. #endif /* !BOOTLOADER */
  50. @@ -1269,6 +1271,7 @@
  51. target/arm/as3525/sansa-fuze/lcd-fuze.c
  52. target/arm/as3525/lcd-as-e200v2-fuze.S
  53. target/arm/as3525/backlight-e200v2-fuze.c
  54. +target/arm/as3525/dbop-as3525.c
  55. #ifndef BOOTLOADER
  56. target/arm/powermgmt-ascodec.c
  57. target/arm/as3525/sansa-fuze/powermgmt-fuze.c
  58. Index: firmware/target/arm/lcd-c200_c200v2.c
  59. ===================================================================
  60. --- firmware/target/arm/lcd-c200_c200v2.c (revision 24186)
  61. +++ firmware/target/arm/lcd-c200_c200v2.c (working copy)
  62. @@ -25,11 +25,8 @@
  63. #include "lcd.h"
  64. #include "kernel.h"
  65. #include "system.h"
  66. -
  67. #ifdef SANSA_C200V2
  68. -/* button driver needs to know if a lcd operation is in progress */
  69. -static bool lcd_busy = false;
  70. -static unsigned short dbop_input = 0xFFFF;
  71. +#include "dbop-as3525.h"
  72. #endif
  73.  
  74. /* Display status */
  75. @@ -183,45 +180,6 @@
  76. lcd_delay(20);
  77. }
  78.  
  79. -static unsigned short lcd_dbop_read(void)
  80. -{
  81. - unsigned int dbop_ctrl_old = DBOP_CTRL;
  82. - unsigned int dbop_timpol23_old = DBOP_TIMPOL_23;
  83. - unsigned int value;
  84. -
  85. - /* make sure that the DBOP FIFO is empty */
  86. - while ((DBOP_STAT & (1<<10)) == 0);
  87. -
  88. - /* write DBOP_DOUT to pre-charge DBOP data lines with a high level */
  89. - DBOP_TIMPOL_23 = 0xe167e167; /* no strobe towards lcd */
  90. - DBOP_CTRL = (1 << 16) | /* enw=1 (enable write) */
  91. - (1 << 12); /* ow=1 (16-bit data width) */
  92. - DBOP_DOUT = 0xFFFF; /* all pins high */
  93. - while ((DBOP_STAT & (1<<10)) == 0);
  94. -
  95. - /* perform a DBOP read */
  96. - DBOP_CTRL = (1 << 15) | /* strd=1 (start read) */
  97. - (1 << 12) | /* ow=1 (16-bit data width) */
  98. - (31 << 0); /* rs_t=31 (read DBOP at end of cycle) */
  99. - while ((DBOP_STAT & (1<<16)) == 0);
  100. - value = DBOP_DIN;
  101. -
  102. - /* restore previous values */
  103. - DBOP_TIMPOL_23 = dbop_timpol23_old;
  104. - DBOP_CTRL = dbop_ctrl_old;
  105. -
  106. - return value;
  107. -}
  108. -
  109. -/* get the DBOP input value, either directly or cached if DBOP is busy */
  110. -unsigned short int lcd_dbop_input(void)
  111. -{
  112. - if (!lcd_busy) {
  113. - dbop_input = lcd_dbop_read();
  114. - }
  115. - return dbop_input;
  116. -}
  117. -
  118. #endif
  119.  
  120. /* LCD init */
  121. @@ -292,13 +250,7 @@
  122.  
  123. void lcd_set_contrast(int val)
  124. {
  125. -#ifdef SANSA_C200V2
  126. - lcd_busy = true;
  127. -#endif
  128. lcd_send_command(R_CONTRAST_CONTROL1, val);
  129. -#ifdef SANSA_C200V2
  130. - lcd_busy = false;
  131. -#endif
  132. }
  133.  
  134. void lcd_set_invert_display(bool yesno)
  135. @@ -313,9 +265,6 @@
  136. if (yesno == is_lcd_enabled)
  137. return;
  138.  
  139. -#ifdef SANSA_C200V2
  140. - lcd_busy = true;
  141. -#endif
  142. if ((is_lcd_enabled = yesno))
  143. {
  144. lcd_send_command(R_STANDBY_OFF, 0);
  145. @@ -326,9 +275,6 @@
  146. {
  147. lcd_send_command(R_STANDBY_ON, 0);
  148. }
  149. -#ifdef SANSA_C200V2
  150. - lcd_busy = false;
  151. -#endif
  152. }
  153. #endif
  154.  
  155. @@ -343,18 +289,12 @@
  156. /* turn the display upside down (call lcd_update() afterwards) */
  157. void lcd_set_flip(bool yesno)
  158. {
  159. -#ifdef SANSA_C200V2
  160. - lcd_busy = true;
  161. -#endif
  162. lcd_send_command(R_DRIVER_OUTPUT_MODE, yesno ? 0x02 : 0x07);
  163. -#ifdef SANSA_C200V2
  164. - lcd_busy = false;
  165. -#endif
  166. }
  167.  
  168. /*** update functions ***/
  169.  
  170. -#if MEMORYSIZE > 2
  171. +#if MEMORYSIZE > 2 /* not for C200V2 */
  172. void lcd_yuv_set_options(unsigned options)
  173. {
  174. lcd_yuv_options = options;
  175. @@ -450,12 +390,6 @@
  176.  
  177. addr = &lcd_framebuffer[y][x];
  178.  
  179. -#ifdef SANSA_C200V2
  180. - lcd_busy = true;
  181. - /* perform a dbop read before doing a potentially lengthy lcd update */
  182. - dbop_input = lcd_dbop_read();
  183. -#endif
  184. -
  185. if (width <= 1) {
  186. /* The X end address must be larger than the X start address, so we
  187. * switch to vertical mode for single column updates and set the
  188. @@ -476,8 +410,4 @@
  189. lcd_write_data(addr, width);
  190. addr += LCD_WIDTH;
  191. } while (--height > 0);
  192. -
  193. -#ifdef SANSA_C200V2
  194. - lcd_busy = false;
  195. -#endif
  196. }
  197. Index: firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c
  198. ===================================================================
  199. --- firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c (revision 24186)
  200. +++ firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c (working copy)
  201. @@ -5,9 +5,9 @@
  202. * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  203. * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  204. * \/ \/ \/ \/ \/
  205. - * $Id: button-e200v2.c 19035 2008-11-07 05:31:05Z jdgordon $
  206. + * $Id: button-c200v2.c 19035 2008-11-07 05:31:05Z jdgordon $
  207. *
  208. - * Copyright (C) 2006 by Barry Wardell
  209. + * Copyright (C) 2006 by Barry Wardell, (C) 2009 by Bertrik Sikken
  210. *
  211. * This program is free software; you can redistribute it and/or
  212. * modify it under the terms of the GNU General Public License
  213. @@ -19,29 +19,20 @@
  214. *
  215. ****************************************************************************/
  216.  
  217. +#include "config.h"
  218. #include "system.h"
  219. #include "button-target.h"
  220. #include "button.h"
  221. #include "backlight.h"
  222. -#include "powermgmt.h"
  223. +#include "dbop-as3525.h"
  224.  
  225. +static unsigned short _dbop_din;
  226.  
  227. -static unsigned short _dbop_din = 0xFFFF;
  228. -
  229. -/* in the lcd driver */
  230. -extern unsigned short int lcd_dbop_input(void);
  231. -
  232. static bool hold_button = false;
  233. #ifndef BOOTLOADER
  234. static bool hold_button_old = false;
  235. #endif
  236.  
  237. -/* for the debug menu */
  238. -unsigned short button_dbop_data(void)
  239. -{
  240. - return _dbop_din;
  241. -}
  242. -
  243. void button_init_device(void)
  244. {
  245. GPIOA_DIR &= ~(1<<3);
  246. @@ -59,7 +50,7 @@
  247. {
  248. int btn = BUTTON_NONE;
  249.  
  250. - _dbop_din = lcd_dbop_input();
  251. + _dbop_din = dbop_read_input();
  252.  
  253. /* hold button handling */
  254. hold_button = ((_dbop_din & (1<<12)) == 0);
  255. Index: firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
  256. ===================================================================
  257. --- firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c (revision 24186)
  258. +++ firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c (working copy)
  259. @@ -26,6 +26,7 @@
  260. #include "debug.h"
  261. #include "system.h"
  262. #include "clock-target.h"
  263. +#include "dbop-as3525.h"
  264.  
  265. /* The controller is unknown, but some registers appear to be the same as the
  266. HD66789R */
  267. @@ -89,8 +90,6 @@
  268. #define R_DISP_CONTROL_REV 0x0000
  269. static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL;
  270.  
  271. -static volatile bool lcd_busy = false;
  272. -
  273. static inline void lcd_delay(int x)
  274. {
  275. do {
  276. @@ -435,8 +434,6 @@
  277. yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
  278. yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
  279.  
  280. - lcd_busy = true;
  281. -
  282. lcd_write_reg(R_ENTRY_MODE,
  283. display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL
  284. );
  285. @@ -473,8 +470,6 @@
  286. }
  287. while (--height > 0);
  288. }
  289. -
  290. - lcd_busy = false;
  291. }
  292.  
  293. /* Update the display.
  294. @@ -484,8 +479,6 @@
  295. if (!display_on)
  296. return;
  297.  
  298. - lcd_busy = true;
  299. -
  300. lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  301.  
  302. /* Set start position and window */
  303. @@ -494,8 +487,6 @@
  304. lcd_write_cmd(R_WRITE_DATA_2_GRAM);
  305.  
  306. lcd_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
  307. -
  308. - lcd_busy = false;
  309. }
  310.  
  311. /* Update a fraction of the display. */
  312. @@ -525,8 +516,6 @@
  313. if (y >= ymax)
  314. return; /* nothing left to do */
  315.  
  316. - lcd_busy = true;
  317. -
  318. lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  319.  
  320. lcd_window(x, y, xmax, ymax);
  321. @@ -541,25 +530,4 @@
  322. ptr += LCD_WIDTH;
  323. }
  324. while (--height >= 0);
  325. -
  326. - lcd_busy = false;
  327. }
  328. -
  329. -/* writes one red pixel outside the visible area, needed for correct
  330. - * dbop reads */
  331. -bool lcd_button_support(void)
  332. -{
  333. - if (lcd_busy)
  334. - return false;
  335. -
  336. - lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  337. -
  338. - /* Set start position and window */
  339. - lcd_window(LCD_WIDTH+1, LCD_HEIGHT+1, LCD_WIDTH+2, LCD_HEIGHT+2);
  340. -
  341. - lcd_write_cmd(R_WRITE_DATA_2_GRAM);
  342. -
  343. - lcd_write_value16(0xf<<12);
  344. -
  345. - return true;
  346. -}
  347. Index: firmware/target/arm/as3525/dbop-as3525.c
  348. ===================================================================
  349. --- firmware/target/arm/as3525/dbop-as3525.c (revision 0)
  350. +++ firmware/target/arm/as3525/dbop-as3525.c (revision 0)
  351. @@ -0,0 +1,71 @@
  352. +/***************************************************************************
  353. + * __________ __ ___.
  354. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
  355. + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
  356. + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  357. + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  358. + * \/ \/ \/ \/ \/
  359. + * $Id$
  360. + *
  361. + * Copyright (C) 2009 by Bertrik Sikken
  362. + *
  363. + * This program is free software; you can redistribute it and/or
  364. + * modify it under the terms of the GNU General Public License
  365. + * as published by the Free Software Foundation; either version 2
  366. + * of the License, or (at your option) any later version.
  367. + *
  368. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  369. + * KIND, either express or implied.
  370. + *
  371. + ****************************************************************************/
  372. +
  373. +#include "config.h"
  374. +#include "as3525.h"
  375. +#include "dbop-as3525.h"
  376. +
  377. +static short int dbop_input_value = 0;
  378. +
  379. +/* read the DBOP data pins */
  380. +unsigned short dbop_read_input(void)
  381. +{
  382. + unsigned int dbop_ctrl_old = DBOP_CTRL;
  383. + unsigned int dbop_timpol23_old = DBOP_TIMPOL_23;
  384. +
  385. + /* make sure that the DBOP FIFO is empty */
  386. + while ((DBOP_STAT & (1<<10)) == 0);
  387. +
  388. + /* write DBOP_DOUT to pre-charge DBOP data lines with a defined level */
  389. + DBOP_TIMPOL_23 = 0xe007e007; /* no strobe towards lcd */
  390. + int delay = 10;
  391. + while (delay--) asm volatile ("nop\n");
  392. + DBOP_CTRL = (1 << 19) | /* tri-state output */
  393. + (1 << 16) | /* enw=1 (enable write) */
  394. + (1 << 12); /* ow=1 (16-bit data width) */
  395. + DBOP_DOUT = DBOP_PRECHARGE;
  396. + while ((DBOP_STAT & (1<<10)) == 0);
  397. +
  398. +#if defined(SANSA_FUZE) || defined(SANSA_E200V2)
  399. + delay = 50;
  400. + while (delay--) asm volatile ("nop\n");
  401. +#endif
  402. +
  403. + /* perform a DBOP read */
  404. + DBOP_CTRL = (1 << 19) | /* tri-state output */
  405. + (1 << 15) | /* strd=1 (start read) */
  406. + (1 << 12) | /* ow=1 (16-bit data width) */
  407. + (31 << 0); /* rs_t=31 (read DBOP at end of cycle) */
  408. + while ((DBOP_STAT & (1<<16)) == 0);
  409. + dbop_input_value = DBOP_DIN;
  410. +
  411. + /* restore previous values */
  412. + DBOP_TIMPOL_23 = dbop_timpol23_old;
  413. + DBOP_CTRL = dbop_ctrl_old;
  414. +
  415. + return dbop_input_value;
  416. +}
  417. +
  418. +/* for the debug menu */
  419. +unsigned short dbop_debug(void)
  420. +{
  421. + return dbop_input_value;
  422. +}
  423. Index: firmware/target/arm/as3525/debug-as3525.c
  424. ===================================================================
  425. --- firmware/target/arm/as3525/debug-as3525.c (revision 24186)
  426. +++ firmware/target/arm/as3525/debug-as3525.c (working copy)
  427. @@ -68,7 +68,7 @@
  428. * if I put the below into a sansa-fuze/debug-target.h, it doesn't work*/
  429. #if defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_C200V2)
  430. #define DEBUG_DBOP
  431. -unsigned short button_dbop_data(void);
  432. +#include "dbop-as3525.h"
  433. #endif
  434.  
  435. static inline unsigned read_cp15 (void)
  436. @@ -392,7 +392,7 @@
  437. #ifdef DEBUG_DBOP
  438. line++;
  439. lcd_puts(0, line++, "[DBOP_DIN]");
  440. - lcd_putsf(0, line++, "DBOP_DIN: %4x", button_dbop_data());
  441. + lcd_putsf(0, line++, "DBOP_DIN: %4x", dbop_debug());
  442. #endif
  443. line++;
  444. lcd_puts(0, line++, "[CP15]");
  445. Index: firmware/target/arm/as3525/dbop-as3525.h
  446. ===================================================================
  447. --- firmware/target/arm/as3525/dbop-as3525.h (revision 0)
  448. +++ firmware/target/arm/as3525/dbop-as3525.h (revision 0)
  449. @@ -0,0 +1,23 @@
  450. +/***************************************************************************
  451. + * __________ __ ___.
  452. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___
  453. + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
  454. + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
  455. + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
  456. + * \/ \/ \/ \/ \/
  457. + * $Id$
  458. + *
  459. + * Copyright (C) 2009 by Bertrik Sikken
  460. + *
  461. + * This program is free software; you can redistribute it and/or
  462. + * modify it under the terms of the GNU General Public License
  463. + * as published by the Free Software Foundation; either version 2
  464. + * of the License, or (at your option) any later version.
  465. + *
  466. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  467. + * KIND, either express or implied.
  468. + *
  469. + ****************************************************************************/
  470. +
  471. +unsigned short int dbop_read_input(void);
  472. +unsigned short dbop_debug(void);
  473. Index: firmware/target/arm/as3525/button-e200v2-fuze.c
  474. ===================================================================
  475. --- firmware/target/arm/as3525/button-e200v2-fuze.c (revision 24186)
  476. +++ firmware/target/arm/as3525/button-e200v2-fuze.c (working copy)
  477. @@ -20,10 +20,12 @@
  478. *
  479. ****************************************************************************/
  480.  
  481. +#include "config.h"
  482. #include "system.h"
  483. #include "button.h"
  484. #include "button-target.h"
  485. #include "backlight.h"
  486. +#include "dbop-as3525.h"
  487.  
  488.  
  489. #ifdef SANSA_FUZE
  490. @@ -32,7 +34,6 @@
  491. #define WHEEL_COUNTER_DIV 4
  492. #define ACCEL_INCREMENT 2
  493. #define ACCEL_SHIFT 2
  494. -#define BUTTON_DELAY 60
  495. #endif
  496.  
  497. #ifdef SANSA_E200V2
  498. @@ -41,12 +42,6 @@
  499. #define WHEEL_COUNTER_DIV 2
  500. #define ACCEL_INCREMENT 3
  501. #define ACCEL_SHIFT 1
  502. -#define BUTTON_DELAY 20
  503. -
  504. -/* read_missed is true if buttons could not
  505. - * be read (see lcd_button_support) */
  506. -static bool read_missed = false;
  507. -
  508. #endif
  509.  
  510. /* Buttons */
  511. @@ -54,11 +49,7 @@
  512. #ifndef BOOTLOADER
  513. static bool hold_button_old = false;
  514. #endif
  515. -static unsigned short _dbop_din = BUTTON_NONE;
  516.  
  517. -/* in the lcd driver */
  518. -extern bool lcd_button_support(void);
  519. -
  520. void button_init_device(void)
  521. {
  522. GPIOA_DIR |= (1<<1);
  523. @@ -66,10 +57,9 @@
  524. }
  525.  
  526. #if !defined(BOOTLOADER) && defined(HAVE_SCROLLWHEEL)
  527. -static void scrollwheel(unsigned short dbop_din)
  528. +static void scrollwheel(unsigned int wheel_value)
  529. {
  530. /* current wheel values, parsed from dbop and the resulting button */
  531. - unsigned wheel_value = 0;
  532. unsigned btn = BUTTON_NONE;
  533. /* old wheel values */
  534. static unsigned old_wheel_value = 0;
  535. @@ -112,8 +102,6 @@
  536. return;
  537. }
  538.  
  539. - wheel_value = (dbop_din >> 13) & (1<<1|1<<0);
  540. -
  541. if (old_wheel_value == wheel_tbl[0][wheel_value])
  542. btn = BUTTON_SCROLL_FWD;
  543. else if (old_wheel_value == wheel_tbl[1][wheel_value])
  544. @@ -158,11 +146,7 @@
  545. last_wheel_post = current_tick;
  546. }
  547. }
  548. - if (accel > 0
  549. -#ifdef SANSA_E200V2
  550. - && !read_missed /* decrement only if reading buttons was successful */
  551. -#endif
  552. - )
  553. + if (accel > 0)
  554. accel--;
  555.  
  556. old_wheel_value = wheel_value;
  557. @@ -174,175 +158,73 @@
  558. return hold_button;
  559. }
  560.  
  561. -static void button_delay(void)
  562. -{
  563. - int i = BUTTON_DELAY;
  564. - while(i--) asm volatile ("nop\n");
  565. -}
  566. -
  567. unsigned short button_read_dbop(void)
  568. {
  569. -#ifdef SANSA_FUZE
  570. - /* skip home and power reading if lcd_button_support was blocked,
  571. - * since the dbop bit 15 is invalid then, and use the old value instead
  572. - * -20 (arbitary value) indicates valid home&power button read
  573. - * (fuze only) */
  574. - int old_home_power = -20;
  575. -#endif
  576. - if(!lcd_button_support())
  577. - {
  578. -#if defined(SANSA_FUZE)
  579. - old_home_power = (_dbop_din & (1<<15|1<<8));
  580. -#elif defined(SANSA_E200V2)
  581. - read_missed = true;
  582. -#endif
  583. - }
  584. -
  585. -#ifdef SANSA_E200V2
  586. - if (!read_missed) /* read buttons only if lcd_button_support was not blocked */
  587. -#endif
  588. - {
  589. - /* Set up dbop for input */
  590. - DBOP_CTRL |= (1<<19); /* Tri-state DBOP on read cycle */
  591. - DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */
  592. - DBOP_TIMPOL_01 = 0xe167e167; /* Set Timing & Polarity regs 0 & 1 */
  593. - DBOP_TIMPOL_23 = 0xe167006e; /* Set Timing & Polarity regs 2 & 3 */
  594. -
  595. - button_delay();
  596. - DBOP_CTRL |= (1<<15); /* start read */
  597. - while (!(DBOP_STAT & (1<<16))); /* wait for valid data */
  598. -
  599. - _dbop_din = DBOP_DIN; /* Read dbop data*/
  600. -
  601. - /* Reset dbop for output */
  602. - DBOP_TIMPOL_01 = 0x6e167; /* Set Timing & Polarity regs 0 & 1 */
  603. - DBOP_TIMPOL_23 = 0xa167e06f; /* Set Timing & Polarity regs 2 & 3 */
  604. - DBOP_CTRL |= (1<<16); /* Enable output (0:write disable) */
  605. - DBOP_CTRL &= ~(1<<19); /* Tri-state when no active write */
  606. - }
  607. -
  608. -#ifdef SANSA_FUZE
  609. - /* write back old values if blocked */
  610. - if (old_home_power != -20)
  611. - {
  612. - _dbop_din |= old_home_power & 1<<15;
  613. - _dbop_din &= 0xfeff|(old_home_power & 1<<8);
  614. - }
  615. -#endif
  616. -
  617. + unsigned dbop_din = dbop_read_input();
  618. #if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER)
  619. - /* read wheel on bit 13 & 14, but sent to the button queue seperately */
  620. - scrollwheel(_dbop_din);
  621. + /* scroll wheel handling */
  622. + scrollwheel((dbop_din >> 13) & (1<<1|1<<0));
  623. #endif
  624. -
  625. -#ifdef SANSA_E200V2
  626. - read_missed = false;
  627. -#endif
  628. -
  629. - return _dbop_din;
  630. + return dbop_din;
  631. }
  632.  
  633. -/* for the debug menu */
  634. -unsigned short button_dbop_data(void)
  635. -{
  636. - return _dbop_din;
  637. -}
  638. -
  639. -static int button_gpio(void)
  640. -{
  641. - int btn = BUTTON_NONE;
  642. - if(hold_button)
  643. - return btn;
  644. -
  645. - /* disable DBOP output while changing GPIO pins that share lines with it */
  646. - DBOP_CTRL &= ~(1<<16);
  647. - button_delay();
  648. -
  649. - /* set afsel, so that we can read our buttons */
  650. - GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
  651. - /* set dir so we can read our buttons (but reset the C pins first) */
  652. - GPIOB_DIR &= ~(1<<4);
  653. - GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
  654. - GPIOC_PIN(2) = (1<<2);
  655. - GPIOC_PIN(3) = (1<<3);
  656. - GPIOC_PIN(4) = (1<<4);
  657. - GPIOC_PIN(5) = (1<<5);
  658. - GPIOC_PIN(6) = (1<<6);
  659. -
  660. - GPIOC_DIR &= ~(1<<2|1<<3|1<<4|1<<5|1<<6);
  661. -
  662. - /* small delay needed to read buttons correctly */
  663. - button_delay();
  664. -
  665. - /* direct GPIO connections */
  666. - if (!GPIOC_PIN(3))
  667. - btn |= BUTTON_LEFT;
  668. - if (!GPIOC_PIN(2))
  669. - btn |= BUTTON_UP;
  670. - if (!GPIOC_PIN(6))
  671. - btn |= BUTTON_DOWN;
  672. - if (!GPIOC_PIN(5))
  673. - btn |= BUTTON_RIGHT;
  674. - if (!GPIOC_PIN(4))
  675. - btn |= BUTTON_SELECT;
  676. - /* return to settings needed for lcd */
  677. - GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6);
  678. - GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6);
  679. -
  680. - DBOP_CTRL |= (1<<16); /* enable output again */
  681. - return btn;
  682. -}
  683. -
  684. /*
  685. * Get button pressed from hardware
  686. */
  687. int button_read_device(void)
  688. {
  689. - int btn = BUTTON_NONE;
  690. - unsigned short dbop = button_read_dbop();
  691. #ifdef SANSA_FUZE
  692. static unsigned power_counter = 0;
  693. #endif
  694. - /* hold button */
  695. - if(dbop & (1<<12))
  696. + unsigned short dbop_din;
  697. + int btn = BUTTON_NONE;
  698. +
  699. + dbop_din = button_read_dbop();
  700. +
  701. + /* hold button handling */
  702. + hold_button = ((dbop_din & (1<<12)) != 0);
  703. +#ifndef BOOTLOADER
  704. + /* light handling */
  705. + if (hold_button != hold_button_old)
  706. {
  707. + hold_button_old = hold_button;
  708. + backlight_hold_changed(hold_button);
  709. + }
  710. +#endif /* BOOTLOADER */
  711. + if (hold_button) {
  712. #ifdef SANSA_FUZE
  713. power_counter = HZ;
  714. #endif
  715. - hold_button = true;
  716. + return 0;
  717. }
  718. - else
  719. - {
  720. - hold_button = false;
  721. +
  722. + /* push button handling */
  723. + if ((dbop_din & (1 << 2)) == 0)
  724. + btn |= BUTTON_UP;
  725. + if ((dbop_din & (1 << 3)) == 0)
  726. + btn |= BUTTON_LEFT;
  727. + if ((dbop_din & (1 << 4)) == 0)
  728. + btn |= BUTTON_SELECT;
  729. + if ((dbop_din & (1 << 5)) == 0)
  730. + btn |= BUTTON_RIGHT;
  731. + if ((dbop_din & (1 << 6)) == 0)
  732. + btn |= BUTTON_DOWN;
  733. + if ((dbop_din & (1 << 8)) != 0)
  734. + btn |= BUTTON_POWER;
  735. + if ((dbop_din & (1 << 15)) == 0)
  736. + btn |= DBOP_BIT15_BUTTON;
  737. +
  738. #ifdef SANSA_FUZE
  739. /* read power on bit 8, but not if hold button was just released, since
  740. * you basically always hit power due to the slider mechanism after releasing
  741. * (fuze only)
  742. - * hold (wait 1 sec) */
  743. - if (power_counter)
  744. + */
  745. + if (power_counter > 0) {
  746. power_counter--;
  747. + btn &= ~BUTTON_POWER;
  748. + }
  749. #endif
  750. - if (dbop & (1<<8)
  751. -#ifdef SANSA_FUZE
  752. - && !power_counter
  753. -#endif
  754. - )
  755. - btn |= BUTTON_POWER;
  756. - /* read home on bit 15 */
  757. - if (!(dbop & (1<<15)))
  758. - btn |= DBOP_BIT15_BUTTON;
  759.  
  760. - btn |= button_gpio();
  761. - }
  762. -
  763. -#ifndef BOOTLOADER
  764. - /* light handling */
  765. - if (hold_button != hold_button_old)
  766. - {
  767. - hold_button_old = hold_button;
  768. - backlight_hold_changed(hold_button);
  769. - }
  770. -#endif /* BOOTLOADER */
  771. -
  772. return btn;
  773. }
  774. +
  775. Index: firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c
  776. ===================================================================
  777. --- firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (revision 24186)
  778. +++ firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (working copy)
  779. @@ -28,6 +28,7 @@
  780. #include "debug.h"
  781. #include "system.h"
  782. #include "clock-target.h"
  783. +#include "dbop-as3525.h"
  784.  
  785. /* The controller is unknown, but some registers appear to be the same as the
  786. HD66789R */
  787. @@ -92,7 +93,6 @@
  788. static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL;
  789.  
  790. static const int xoffset = 20;
  791. -static volatile bool lcd_busy = false;
  792.  
  793. static inline void lcd_delay(int x)
  794. {
  795. @@ -379,8 +379,6 @@
  796. yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
  797. yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
  798.  
  799. - lcd_busy = true;
  800. -
  801. #ifdef HAVE_LCD_FLIP
  802. lcd_write_reg(R_ENTRY_MODE,
  803. display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL
  804. @@ -423,8 +421,6 @@
  805. }
  806. while (--height > 0);
  807. }
  808. -
  809. - lcd_busy = false;
  810. }
  811.  
  812. /* Update the display.
  813. @@ -434,8 +430,6 @@
  814. if (!display_on)
  815. return;
  816.  
  817. - lcd_busy = true;
  818. -
  819. lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  820.  
  821. lcd_window_x(0, LCD_WIDTH - 1);
  822. @@ -444,8 +438,6 @@
  823. lcd_write_cmd(R_WRITE_DATA_2_GRAM);
  824.  
  825. lcd_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
  826. -
  827. - lcd_busy = false;
  828. }
  829.  
  830. /* Update a fraction of the display. */
  831. @@ -475,8 +467,6 @@
  832. if (y >= ymax)
  833. return; /* nothing left to do */
  834.  
  835. - lcd_busy = true;
  836. -
  837. lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  838.  
  839. lcd_window_x(x, xmax);
  840. @@ -493,26 +483,4 @@
  841. ptr += LCD_WIDTH;
  842. }
  843. while (--height >= 0);
  844. -
  845. - lcd_busy = false;
  846. }
  847. -
  848. -/* writes one red pixel outside the visible area, needed for correct
  849. - * dbop reads */
  850. -bool lcd_button_support(void)
  851. -{
  852. - if (lcd_busy)
  853. - return false;
  854. -
  855. - lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
  856. -
  857. - /* Set start position and window */
  858. - lcd_window_x(-1, 0);
  859. - lcd_window_y(-1, 0);
  860. -
  861. - lcd_write_cmd(R_WRITE_DATA_2_GRAM);
  862. -
  863. - lcd_write_value16(0xf<<12);
  864. -
  865. - return true;
  866. -}
Add Comment
Please, Sign In to add comment