You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2026/04/11 13:39:35 UTC
(nuttx-apps) 02/02: include/debug.h: fix checkpatch fallout in touched apps files
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 96a003072d596d2e1b81ff3fd944692877e5bae3
Author: Piyush Patle <pi...@gmail.com>
AuthorDate: Sat Apr 11 03:50:44 2026 +0530
include/debug.h: fix checkpatch fallout in touched apps files
Clean up style issues in the files touched by the <nuttx/debug.h> include
migration so the full apps-side PR passes checkpatch.
Signed-off-by: Piyush Patle <pi...@gmail.com>
---
examples/nx/nx_events.c | 54 ++++++----
examples/nx/nx_kbdin.c | 83 ++++++++-------
examples/nx/nx_main.c | 160 +++++++++++++++++-----------
examples/nxhello/nxhello_bkgd.c | 72 +++++++------
examples/nxhello/nxhello_main.c | 87 +++++++--------
examples/nximage/nximage_bkgd.c | 61 ++++++-----
examples/nximage/nximage_main.c | 91 ++++++++--------
examples/nxlines/nxlines_main.c | 90 ++++++++--------
examples/nxterm/nxterm_toolbar.c | 9 +-
examples/nxterm/nxterm_wndo.c | 16 ++-
examples/nxtext/nxtext_bkgd.c | 33 +++---
examples/nxtext/nxtext_main.c | 88 +++++++++-------
examples/nxtext/nxtext_putc.c | 86 ++++++++-------
examples/pwfb/pwfb_main.c | 63 ++++++-----
examples/pwlines/pwlines_main.c | 69 ++++++------
examples/qencoder/qe_main.c | 19 ++--
fsutils/flash_eraseall/flash_eraseall.c | 5 +-
graphics/tiff/tiff_addstrip.c | 25 +++--
graphics/tiff/tiff_initialize.c | 180 ++++++++++++++++++++++----------
graphics/tiff/tiff_utils.c | 37 ++++---
system/nxcamera/nxcamera.c | 116 ++++++++++----------
21 files changed, 842 insertions(+), 602 deletions(-)
diff --git a/examples/nx/nx_events.c b/examples/nx/nx_events.c
index 4e5616641..065c4e3cf 100644
--- a/examples/nx/nx_events.c
+++ b/examples/nx/nx_events.c
@@ -52,25 +52,30 @@
static void nxeg_redraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
bool morem, FAR void *arg);
-static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxeg_position(NXEGWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+static void nxeg_mousein(NXEGWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
uint8_t buttons, FAR void *arg);
#endif
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+static void nxeg_tbredraw(NXEGWINDOW hwnd,
+ FAR const struct nxgl_rect_s *rect,
bool morem, FAR void *arg);
-static void nxeg_tbposition(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxeg_tbposition(NXEGWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg);
+static void nxeg_tbmousein(NXEGWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg);
#endif
#endif
@@ -137,6 +142,7 @@ static inline void nxeg_fillwindow(NXEGWINDOW hwnd,
printf("nxeg_fillwindow: nxtk_fillwindow failed: %d\n", errno);
}
#endif
+
#ifdef CONFIG_NX_KBD
nxeg_filltext(hwnd, rect, st);
#endif
@@ -148,8 +154,8 @@ static inline void nxeg_fillwindow(NXEGWINDOW hwnd,
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
static inline void nxeg_filltoolbar(NXTKWINDOW htb,
- FAR const struct nxgl_rect_s *rect,
- nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
+ FAR const struct nxgl_rect_s *rect,
+ nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
{
int ret;
@@ -181,7 +187,8 @@ static void nxeg_redraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nxeg_position
****************************************************************************/
-static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxeg_position(NXEGWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg)
@@ -190,7 +197,8 @@ static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
/* Report the position */
- printf("nxeg_position%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
+ printf("nxeg_position%d: hwnd=%p size=(%d,%d) pos=(%d,%d) "
+ "bounds={(%d,%d),(%d,%d)}\n",
st->wnum, hwnd, size->w, size->h, pos->x, pos->y,
bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
@@ -198,7 +206,9 @@ static void nxeg_position(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
if (!b_haveresolution)
{
- /* Save the window limits (these should be the same for all places and all windows */
+ /* Save the window limits (these should be the same for all places
+ * and all windows.
+ */
g_xres = bounds->pt2.x;
g_yres = bounds->pt2.y;
@@ -228,7 +238,8 @@ static void nxeg_mousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
+static void nxeg_tbredraw(NXEGWINDOW hwnd,
+ FAR const struct nxgl_rect_s *rect,
bool more, FAR void *arg)
{
FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg;
@@ -245,16 +256,18 @@ static void nxeg_tbredraw(NXEGWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static void nxeg_tbposition(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg)
+static void nxeg_tbposition(NXEGWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg)
{
FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg;
/* Report the position */
- printf("nxeg_ptbosition%d: hwnd=%p size=(%d,%d) pos=(%d,%d) bounds={(%d,%d),(%d,%d)}\n",
+ printf("nxeg_ptbosition%d: hwnd=%p size=(%d,%d) pos=(%d,%d) "
+ "bounds={(%d,%d),(%d,%d)}\n",
st->wnum, hwnd, size->w, size->h, pos->x, pos->y,
bounds->pt1.x, bounds->pt1.y, bounds->pt2.x, bounds->pt2.y);
}
@@ -266,8 +279,9 @@ static void nxeg_tbposition(NXEGWINDOW hwnd, FAR const struct nxgl_size_s *size,
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
#ifdef CONFIG_NX_XYINPUT
-static void nxeg_tbmousein(NXEGWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg)
+static void nxeg_tbmousein(NXEGWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg)
{
FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg;
@@ -291,7 +305,7 @@ FAR void *nx_listenerthread(FAR void *arg)
/* Process events forever */
- for (;;)
+ for (; ; )
{
/* Handle the next event. If we were configured blocking, then
* we will stay right here until the next event is received. Since
diff --git a/examples/nx/nx_kbdin.c b/examples/nx/nx_kbdin.c
index cdab7fe20..51f0e7efd 100644
--- a/examples/nx/nx_kbdin.c
+++ b/examples/nx/nx_kbdin.c
@@ -109,7 +109,8 @@ static void nxeg_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
if (!nxgl_nullrect(&intersection))
{
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
- ret = nxtk_bitmapwindow((NXTKWINDOW)hwnd, &intersection, (FAR const void **)&src,
+ ret = nxtk_bitmapwindow((NXTKWINDOW)hwnd, &intersection,
+ (FAR const void **)&src,
&bm->bounds.pt1,
(unsigned int)bm->glyph->stride);
if (ret < 0)
@@ -165,7 +166,7 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st,
/* Allocate memory to hold the glyph with its offsets */
glyph->stride = (glyph->width * CONFIG_EXAMPLES_NX_BPP + 7) / 8;
- bmsize = glyph->stride * glyph->height;
+ bmsize = glyph->stride * glyph->height;
glyph->bitmap = (FAR uint8_t *)malloc(bmsize);
if (glyph->bitmap)
@@ -178,13 +179,13 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st,
/* Pack 1-bit pixels into a 2-bits */
pixel &= 0x01;
- pixel = (pixel) << 1 |pixel;
+ pixel = (pixel) << 1 | pixel;
# endif
# if CONFIG_EXAMPLES_NX_BPP < 4
/* Pack 2-bit pixels into a nibble */
pixel &= 0x03;
- pixel = (pixel) << 2 |pixel;
+ pixel = (pixel) << 2 | pixel;
# endif
/* Pack 4-bit nibbles into a byte */
@@ -222,7 +223,7 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st,
/* Then render the glyph into the allocated memory */
- ret = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap,
+ ret = RENDERER((FAR nxgl_mxpixel_t *)glyph->bitmap,
glyph->height, glyph->width, glyph->stride,
bm, CONFIG_EXAMPLES_NX_FONTCOLOR);
if (ret < 0)
@@ -236,9 +237,9 @@ nxeg_renderglyph(FAR struct nxeg_state_s *st,
}
else
{
- /* Make it permanent */
+ /* Make it permanent */
- st->nglyphs++;
+ st->nglyphs++;
}
}
}
@@ -269,6 +270,7 @@ nxeg_addspace(FAR struct nxeg_state_s *st, uint8_t ch)
st->nglyphs++;
}
+
return glyph;
}
@@ -283,13 +285,14 @@ nxeg_findglyph(FAR struct nxeg_state_s *st, uint8_t ch)
/* First, try to find the glyph in the cache of pre-rendered glyphs */
- for (i = 0; i < st->nglyphs; i++)
+ for (i = 0; i < st->nglyphs; i++)
{
if (st->glyph[i].code == ch)
{
return &st->glyph[i];
}
}
+
return NULL;
}
@@ -313,21 +316,22 @@ nxeg_getglyph(FAR struct nxeg_state_s *st, uint8_t ch)
bm = nxf_getbitmap(g_fonthandle, ch);
if (!bm)
{
- /* No, there is no glyph for this code. Use space */
+ /* No, there is no glyph for this code. Use space. */
glyph = nxeg_findglyph(st, ' ');
if (!glyph)
{
- /* There isn't fake glyph for ' ' yet... create one */
+ /* There isn't a fake glyph for ' ' yet... create one */
glyph = nxeg_addspace(st, ' ');
}
}
else
{
- glyph = nxeg_renderglyph(st, bm, ch);
+ glyph = nxeg_renderglyph(st, bm, ch);
}
}
+
return glyph;
}
@@ -346,41 +350,42 @@ nxeg_addchar(FAR struct nxeg_state_s *st, uint8_t ch)
if (st->nchars < NXTK_MAXKBDCHARS)
{
- /* Yes, setup the bitmap */
+ /* Yes, setup the bitmap */
- bm = &st->bm[st->nchars];
+ bm = &st->bm[st->nchars];
- /* Find the matching glyph */
+ /* Find the matching glyph */
- bm->glyph = nxeg_getglyph(st, ch);
- if (!bm->glyph)
- {
- return NULL;
- }
+ bm->glyph = nxeg_getglyph(st, ch);
+ if (!bm->glyph)
+ {
+ return NULL;
+ }
- /* Set up the bounds for the bitmap */
+ /* Set up the bounds for the bitmap */
- if (st->nchars <= 0)
- {
- /* The first character is one space from the left */
+ if (st->nchars <= 0)
+ {
+ /* The first character is one space from the left */
- leftx = st->spwidth;
- }
- else
- {
- /* Otherwise, it is to the left of the preceding char */
+ leftx = st->spwidth;
+ }
+ else
+ {
+ /* Otherwise, it is to the left of the preceding char */
- bmleft = &st->bm[st->nchars-1];
- leftx = bmleft->bounds.pt2.x + 1;
- }
+ bmleft = &st->bm[st->nchars - 1];
+ leftx = bmleft->bounds.pt2.x + 1;
+ }
- bm->bounds.pt1.x = leftx;
- bm->bounds.pt1.y = 2;
- bm->bounds.pt2.x = leftx + bm->glyph->width - 1;
- bm->bounds.pt2.y = 2 + bm->glyph->height - 1;
+ bm->bounds.pt1.x = leftx;
+ bm->bounds.pt1.y = 2;
+ bm->bounds.pt2.x = leftx + bm->glyph->width - 1;
+ bm->bounds.pt2.y = 2 + bm->glyph->height - 1;
- st->nchars++;
+ st->nchars++;
}
+
return bm;
}
@@ -424,10 +429,12 @@ void nxeg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
****************************************************************************/
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
-void nxeg_tbkbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch, FAR void *arg)
+void nxeg_tbkbdin(NXWINDOW hwnd, uint8_t nch, const uint8_t *ch,
+ FAR void *arg)
{
FAR struct nxeg_state_s *st = (FAR struct nxeg_state_s *)arg;
- printf("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard input\n");
+ printf("nxeg_tbkbdin: ERROR -- toolbar should not received keyboard "
+ "input\n");
printf("nxeg_tbkbdin%d: hwnd=%p nch=%d\n", st->wnum, hwnd, nch);
}
#endif
diff --git a/examples/nx/nx_main.c b/examples/nx/nx_main.c
index 942d59870..9bdeded9c 100644
--- a/examples/nx/nx_main.c
+++ b/examples/nx/nx_main.c
@@ -54,6 +54,7 @@
****************************************************************************/
/* Configuration ************************************************************/
+
/* If not specified, assume that the hardware supports one video plane */
#ifndef CONFIG_EXAMPLES_NX_VPLANE
@@ -98,7 +99,10 @@ nxgl_coord_t g_yres;
bool b_haveresolution = false;
bool g_connected = false;
-sem_t g_semevent = {0};
+sem_t g_semevent =
+{
+ 0
+};
/* Colors used to fill window 1 & 2 */
@@ -181,14 +185,16 @@ static void nxeg_freestate(FAR struct nxeg_state_s *st)
{
for (i = 0; i < st->nglyphs; i++)
{
- if (st->glyph[i].bitmap)
- {
- free(st->glyph[i].bitmap);
- }
- st->glyph[i].bitmap = NULL;
+ if (st->glyph[i].bitmap)
+ {
+ free(st->glyph[i].bitmap);
+ }
+
+ st->glyph[i].bitmap = NULL;
}
+
st->nchars = 0;
- }
+ }
#endif
}
#endif
@@ -199,7 +205,7 @@ static void nxeg_freestate(FAR struct nxeg_state_s *st)
#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
- FAR struct nxeg_state_s *state)
+ FAR struct nxeg_state_s *state)
{
NXEGWINDOW hwnd;
@@ -209,8 +215,10 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
printf("nxeg_openwindow: nx_openwindow failed: %d\n", errno);
g_exitcode = NXEXIT_NXOPENWINDOW;
}
+
return hwnd;
}
+
#else
static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
FAR struct nxeg_state_s *state)
@@ -223,8 +231,10 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
printf("nxeg_openwindow: nxtk_openwindow failed: %d\n", errno);
g_exitcode = NXEXIT_NXOPENWINDOW;
}
+
return hwnd;
}
+
#endif
/****************************************************************************
@@ -232,7 +242,8 @@ static inline NXEGWINDOW nxeg_openwindow(FAR const struct nx_callback_s *cb,
****************************************************************************/
#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *state)
+static inline int nxeg_closewindow(NXEGWINDOW hwnd,
+ FAR struct nxeg_state_s *state)
{
int ret = nx_closewindow(hwnd);
if (ret < 0)
@@ -240,10 +251,13 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta
printf("nxeg_closewindow: nx_closewindow failed: %d\n", errno);
g_exitcode = NXEXIT_NXCLOSEWINDOW;
}
+
return ret;
}
+
#else
-static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *state)
+static inline int nxeg_closewindow(NXEGWINDOW hwnd,
+ FAR struct nxeg_state_s *state)
{
int ret = nxtk_closewindow(hwnd);
if (ret < 0)
@@ -251,9 +265,11 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta
printf("nxeg_closewindow: nxtk_closewindow failed: %d\n", errno);
g_exitcode = NXEXIT_NXCLOSEWINDOW;
}
+
nxeg_freestate(state);
return ret;
}
+
#endif
/****************************************************************************
@@ -261,7 +277,8 @@ static inline int nxeg_closewindow(NXEGWINDOW hwnd, FAR struct nxeg_state_s *sta
****************************************************************************/
#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
+static inline int nxeg_setsize(NXEGWINDOW hwnd,
+ FAR struct nxgl_size_s *size)
{
int ret = nx_setsize(hwnd, size);
if (ret < 0)
@@ -269,10 +286,13 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
printf("nxeg_setsize: nx_setsize failed: %d\n", errno);
g_exitcode = NXEXIT_NXSETSIZE;
}
+
return ret;
}
+
#else
-static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
+static inline int nxeg_setsize(NXEGWINDOW hwnd,
+ FAR struct nxgl_size_s *size)
{
int ret = nxtk_setsize(hwnd, size);
if (ret < 0)
@@ -280,8 +300,10 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
printf("nxeg_setsize: nxtk_setsize failed: %d\n", errno);
g_exitcode = NXEXIT_NXSETSIZE;
}
+
return ret;
}
+
#endif
/****************************************************************************
@@ -289,7 +311,8 @@ static inline int nxeg_setsize(NXEGWINDOW hwnd, FAR struct nxgl_size_s *size)
****************************************************************************/
#ifdef CONFIG_EXAMPLES_NX_RAWWINDOWS
-static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos)
+static inline int nxeg_setposition(NXEGWINDOW hwnd,
+ FAR struct nxgl_point_s *pos)
{
int ret = nx_setposition(hwnd, pos);
if (ret < 0)
@@ -297,10 +320,13 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos
printf("nxeg_setposition: nx_setposition failed: %d\n", errno);
g_exitcode = NXEXIT_NXSETPOSITION;
}
+
return ret;
}
+
#else
-static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos)
+static inline int nxeg_setposition(NXEGWINDOW hwnd,
+ FAR struct nxgl_point_s *pos)
{
int ret = nxtk_setposition(hwnd, pos);
if (ret < 0)
@@ -308,8 +334,10 @@ static inline int nxeg_setposition(NXEGWINDOW hwnd, FAR struct nxgl_point_s *pos
printf("nxeg_setposition: nxtk_setposition failed: %d\n", errno);
g_exitcode = NXEXIT_NXSETPOSITION;
}
+
return ret;
}
+
#endif
/****************************************************************************
@@ -328,8 +356,10 @@ static inline int nxeq_opentoolbar(NXEGWINDOW hwnd, nxgl_coord_t height,
printf("nxeq_opentoolbar: nxtk_opentoolbar failed: %d\n", errno);
g_exitcode = NXEXIT_NXOPENTOOLBAR;
}
+
return ret;
}
+
#endif
/****************************************************************************
@@ -345,8 +375,10 @@ static inline int nxeg_lower(NXEGWINDOW hwnd)
printf("nxeg_lower: nx_lower failed: %d\n", errno);
g_exitcode = NXEXIT_NXLOWER;
}
+
return ret;
}
+
#else
static inline int nxeg_lower(NXEGWINDOW hwnd)
{
@@ -356,8 +388,10 @@ static inline int nxeg_lower(NXEGWINDOW hwnd)
printf("nxeg_lower: nxtk_lower failed: %d\n", errno);
g_exitcode = NXEXIT_NXLOWER;
}
+
return ret;
}
+
#endif
/****************************************************************************
@@ -373,8 +407,10 @@ static inline int nxeg_raise(NXEGWINDOW hwnd)
printf("nxeg_raise: nx_raise failed: %d\n", errno);
g_exitcode = NXEXIT_NXRAISE;
}
+
return ret;
}
+
#else
static inline int nxeg_raise(NXEGWINDOW hwnd)
{
@@ -384,8 +420,10 @@ static inline int nxeg_raise(NXEGWINDOW hwnd)
printf("nxeg_raise: nxtk_raise failed: %d\n", errno);
g_exitcode = NXEXIT_NXRAISE;
}
+
return ret;
}
+
#endif
/****************************************************************************
@@ -416,7 +454,7 @@ static int nxeg_initialize(void)
ret = sched_setparam(0, ¶m);
if (ret < 0)
{
- printf("nxeg_initialize: sched_setparam failed: %d\n" , ret);
+ printf("nxeg_initialize: sched_setparam failed: %d\n", ret);
g_exitcode = NXEXIT_SCHEDSETPARAM;
return ERROR;
}
@@ -426,7 +464,8 @@ static int nxeg_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
- printf("nxeg_initialize: Failed to start the NX server: %d\n", errno);
+ printf("nxeg_initialize: Failed to start the NX server: %d\n",
+ errno);
g_exitcode = NXEXIT_TASKCREATE;
return ERROR;
}
@@ -436,54 +475,54 @@ static int nxeg_initialize(void)
g_hnx = nx_connect();
if (g_hnx)
{
- pthread_attr_t attr;
+ pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, g_hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
- nx_disconnect(g_hnx);
- g_exitcode = NXEXIT_FBINITIALIZE;
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, g_hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+ nx_disconnect(g_hnx);
+ g_exitcode = NXEXIT_FBINITIALIZE;
+ return ERROR;
+ }
#endif
- /* Start a separate thread to listen for server events. This is probably
- * the least efficient way to do this, but it makes this example flow more
- * smoothly.
- */
+ /* Start a separate thread to listen for server events. This is
+ * probably the least efficient way to do this, but it makes this
+ * example flow more smoothly.
+ */
- pthread_attr_init(&attr);
- param.sched_priority = CONFIG_EXAMPLES_NX_LISTENERPRIO;
- pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NX_STACKSIZE);
+ pthread_attr_init(&attr);
+ param.sched_priority = CONFIG_EXAMPLES_NX_LISTENERPRIO;
+ pthread_attr_setschedparam(&attr, ¶m);
+ pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NX_STACKSIZE);
- ret = pthread_create(&thread, &attr, nx_listenerthread, NULL);
- if (ret != 0)
- {
- printf("nxeg_initialize: pthread_create failed: %d\n", ret);
- g_exitcode = NXEXIT_PTHREADCREATE;
- return ERROR;
- }
+ ret = pthread_create(&thread, &attr, nx_listenerthread, NULL);
+ if (ret != 0)
+ {
+ printf("nxeg_initialize: pthread_create failed: %d\n", ret);
+ g_exitcode = NXEXIT_PTHREADCREATE;
+ return ERROR;
+ }
- /* Don't return until we are connected to the server */
+ /* Don't return until we are connected to the server */
- while (!g_connected)
- {
- /* Wait for the listener thread to wake us up when we really
- * are connected.
- */
+ while (!g_connected)
+ {
+ /* Wait for the listener thread to wake us up when we really
+ * are connected.
+ */
- sem_wait(&g_semevent);
- }
+ sem_wait(&g_semevent);
+ }
}
else
{
@@ -562,6 +601,7 @@ int main(int argc, FAR char *argv[])
{
sem_wait(&g_semevent);
}
+
printf("nx_main: Screen resolution (%d,%d)\n", g_xres, g_yres);
/* Set the size of the window 1 */
@@ -576,9 +616,8 @@ int main(int argc, FAR char *argv[])
goto errout_with_hwnd1;
}
- /* Sleep a bit -- both so that we can see the result of the above operations
- * but also, in the multi-user case, so that the server can get a chance to
- * actually do them!
+ /* Sleep a bit. This lets us see the result of the above operations and,
+ * in the multi-user case, gives the server a chance to actually do them.
*/
printf("nx_main: Sleeping\n\n");
@@ -605,7 +644,8 @@ int main(int argc, FAR char *argv[])
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
printf("nx_main: Add toolbar to window #1\n");
- ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]);
+ ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT,
+ &g_tbcb, &g_wstate[0]);
if (ret < 0)
{
goto errout_with_hwnd1;
@@ -633,7 +673,7 @@ int main(int argc, FAR char *argv[])
printf("nx_main: Sleeping\n\n");
sleep(1);
- /* Set the size of the window 2 == size of window 1*/
+ /* Set the size of window 2 equal to the size of window 1 */
printf("nx_main: Set hwnd2 size to (%d,%d)\n", size.w, size.h);
ret = nxeg_setsize(hwnd2, &size);
@@ -666,7 +706,8 @@ int main(int argc, FAR char *argv[])
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
printf("nx_main: Add toolbar to window #2\n");
- ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]);
+ ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT,
+ &g_tbcb, &g_wstate[1]);
if (ret < 0)
{
goto errout_with_hwnd2;
@@ -770,6 +811,7 @@ errout_with_hwnd1:
nxeg_closewindow(hwnd1, &g_wstate[0]);
errout_with_nx:
+
/* Disconnect from the server */
printf("nx_main: Disconnect from the server\n");
diff --git a/examples/nxhello/nxhello_bkgd.c b/examples/nxhello/nxhello_bkgd.c
index 323b4870d..5e0a5b80e 100644
--- a/examples/nxhello/nxhello_bkgd.c
+++ b/examples/nxhello/nxhello_bkgd.c
@@ -76,19 +76,21 @@
****************************************************************************/
static void nxhello_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- bool morem, FAR void *arg);
-static void nxhello_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg);
+ bool morem, FAR void *arg);
+static void nxhello_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nxhello_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg);
+static void nxhello_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg);
#endif
#ifdef CONFIG_NX_KBD
-static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
- FAR void *arg);
+static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch,
+ FAR const uint8_t *ch, FAR void *arg);
#endif
/****************************************************************************
@@ -125,7 +127,7 @@ const struct nx_callback_s g_nxhellocb =
****************************************************************************/
static void nxhello_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- bool more, FAR void *arg)
+ bool more, FAR void *arg)
{
ginfo("hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
@@ -136,10 +138,11 @@ static void nxhello_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nxhello_position
****************************************************************************/
-static void nxhello_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg)
+static void nxhello_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg)
{
/* Report the position */
@@ -171,8 +174,9 @@ static void nxhello_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
****************************************************************************/
#ifdef CONFIG_NX_XYINPUT
-static void nxhello_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg)
+static void nxhello_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg)
{
printf("nxhello_mousein: hwnd=%p pos=(%d,%d) button=%02x\n",
hwnd, pos->x, pos->y, buttons);
@@ -184,16 +188,16 @@ static void nxhello_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
****************************************************************************/
#ifdef CONFIG_NX_KBD
-static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
- FAR void *arg)
+static void nxhello_kbdin(NXWINDOW hwnd, uint8_t nch,
+ FAR const uint8_t *ch, FAR void *arg)
{
ginfo("hwnd=%p nch=%d\n", hwnd, nch);
- /* In this example, there is no keyboard so a keyboard event is not
- * expected.
- */
+ /* In this example, there is no keyboard so a keyboard event is not
+ * expected.
+ */
- printf("nxhello_kbdin: Unexpected keyboard callback\n");
+ printf("nxhello_kbdin: Unexpected keyboard callback\n");
}
#endif
@@ -212,7 +216,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos,
* hello world message.
*/
- for (ptr = (uint8_t*)g_hello, width = 0; *ptr; ptr++)
+ for (ptr = (uint8_t *)g_hello, width = 0; *ptr; ptr++)
{
/* Get the font bitmap for this character */
@@ -225,7 +229,7 @@ static void nxhello_center(FAR struct nxgl_point_s *pos,
}
else
{
- /* Use the width of a space */
+ /* Use the width of a space */
width += fontset->spwidth;
}
@@ -266,7 +270,7 @@ static void nxhello_initglyph(FAR uint8_t *glyph, uint8_t height,
/* Pack 1-bit pixels into a 2-bits */
pixel &= 0x01;
- pixel = (pixel) << 1 |pixel;
+ pixel = (pixel) << 1 | pixel;
# endif
# if CONFIG_EXAMPLES_NXHELLO_BPP < 4
@@ -274,7 +278,7 @@ static void nxhello_initglyph(FAR uint8_t *glyph, uint8_t height,
/* Pack 2-bit pixels into a nibble */
pixel &= 0x03;
- pixel = (pixel) << 2 |pixel;
+ pixel = (pixel) << 2 | pixel;
# endif
@@ -348,10 +352,10 @@ void nxhello_hello(NXWINDOW hwnd)
mxstride = (fontset->mxwidth * CONFIG_EXAMPLES_NXHELLO_BPP + 7) >> 3;
glyphsize = (unsigned int)fontset->mxheight * mxstride;
- glyph = (FAR uint8_t*)malloc(glyphsize);
+ glyph = (FAR uint8_t *)malloc(glyphsize);
- /* NOTE: no check for failure to allocate the memory. In a real application
- * you would need to handle that event.
+ /* NOTE: no check for failure to allocate the memory. In a real
+ * application you would need to handle that event.
*/
/* Get a position so the "Hello, World!" string will be centered on the
@@ -389,7 +393,7 @@ void nxhello_hello(NXWINDOW hwnd)
#if CONFIG_NX_NPLANES > 1
# warning "More logic is needed for the case where CONFIG_NX_PLANES > 1"
#endif
- RENDERER((FAR nxgl_mxpixel_t*)glyph, fheight, fwidth,
+ RENDERER((FAR nxgl_mxpixel_t *)glyph, fheight, fwidth,
fstride, fbm, CONFIG_EXAMPLES_NXHELLO_FONTCOLOR);
/* Describe the destination of the font with a rectangle */
@@ -411,15 +415,15 @@ void nxhello_hello(NXWINDOW hwnd)
printf("nxhello_write: nx_bitmapwindow failed: %d\n", errno);
}
- /* Skip to the right the width of the font */
+ /* Skip to the right the width of the font */
pos.x += fwidth;
}
else
{
- /* No bitmap (probably because the font is a space). Skip to the
- * right the width of a space.
- */
+ /* No bitmap (probably because the font is a space). Skip to the
+ * right the width of a space.
+ */
pos.x += fontset->spwidth;
}
diff --git a/examples/nxhello/nxhello_main.c b/examples/nxhello/nxhello_main.c
index 8165d9abe..d524f6f2c 100644
--- a/examples/nxhello/nxhello_main.c
+++ b/examples/nxhello/nxhello_main.c
@@ -95,7 +95,8 @@ static inline int nxhello_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
- printf("nxhello_initialize: Failed to start the NX server: %d\n", errno);
+ printf("nxhello_initialize: Failed to start the NX server: %d\n",
+ errno);
return ERROR;
}
@@ -104,52 +105,53 @@ static inline int nxhello_initialize(void)
g_nxhello.hnx = nx_connect();
if (g_nxhello.hnx)
{
- pthread_attr_t attr;
+ pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, g_nxhello.hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
- nx_disconnect(g_nxhello.hnx);
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, g_nxhello.hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+ nx_disconnect(g_nxhello.hnx);
+ return ERROR;
+ }
#endif
- /* Start a separate thread to listen for server events. This is probably
- * the least efficient way to do this, but it makes this example flow more
- * smoothly.
- */
-
- pthread_attr_init(&attr);
- param.sched_priority = CONFIG_EXAMPLES_NXHELLO_LISTENERPRIO;
- pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXHELLO_LISTENER_STACKSIZE);
-
- ret = pthread_create(&thread, &attr, nxhello_listener, NULL);
- if (ret != 0)
- {
- printf("nxhello_initialize: pthread_create failed: %d\n", ret);
- return ERROR;
- }
-
- /* Don't return until we are connected to the server */
-
- while (!g_nxhello.connected)
- {
- /* Wait for the listener thread to wake us up when we really
- * are connected.
- */
-
- sem_wait(&g_nxhello.eventsem);
- }
+ /* Start a separate thread to listen for server events. This is
+ * probably the least efficient way to do this, but it makes this
+ * example flow more smoothly.
+ */
+
+ pthread_attr_init(&attr);
+ param.sched_priority = CONFIG_EXAMPLES_NXHELLO_LISTENERPRIO;
+ pthread_attr_setschedparam(&attr, ¶m);
+ pthread_attr_setstacksize(&attr,
+ CONFIG_EXAMPLES_NXHELLO_LISTENER_STACKSIZE);
+
+ ret = pthread_create(&thread, &attr, nxhello_listener, NULL);
+ if (ret != 0)
+ {
+ printf("nxhello_initialize: pthread_create failed: %d\n", ret);
+ return ERROR;
+ }
+
+ /* Don't return until we are connected to the server */
+
+ while (!g_nxhello.connected)
+ {
+ /* Wait for the listener thread to wake us up when we really
+ * are connected.
+ */
+
+ sem_wait(&g_nxhello.eventsem);
+ }
}
else
{
@@ -225,7 +227,8 @@ int main(int argc, FAR char *argv[])
sem_wait(&g_nxhello.eventsem);
}
- printf("nxhello_main: Screen resolution (%d,%d)\n", g_nxhello.xres, g_nxhello.yres);
+ printf("nxhello_main: Screen resolution (%d,%d)\n",
+ g_nxhello.xres, g_nxhello.yres);
/* Now, say hello and exit, sleeping a little before each. */
diff --git a/examples/nximage/nximage_bkgd.c b/examples/nximage/nximage_bkgd.c
index 8a86f0498..8e3a2f651 100644
--- a/examples/nximage/nximage_bkgd.c
+++ b/examples/nximage/nximage_bkgd.c
@@ -109,19 +109,21 @@ struct nximage_run_s
****************************************************************************/
static void nximage_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- bool more, FAR void *arg);
-static void nximage_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg);
+ bool more, FAR void *arg);
+static void nximage_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nximage_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg);
+static void nximage_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg);
#endif
#ifdef CONFIG_NX_KBD
-static void nximage_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
- FAR void *arg);
+static void nximage_kbdin(NXWINDOW hwnd, uint8_t nch,
+ FAR const uint8_t *ch, FAR void *arg);
#endif
/****************************************************************************
@@ -164,7 +166,7 @@ const struct nx_callback_s g_nximagecb =
****************************************************************************/
static void nximage_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
- bool more, FAR void *arg)
+ bool more, FAR void *arg)
{
ginfo("hwnd=%p rect={(%d,%d),(%d,%d)} more=%s\n",
hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y,
@@ -179,10 +181,11 @@ static void nximage_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
*
****************************************************************************/
-static void nximage_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
- FAR const struct nxgl_point_s *pos,
- FAR const struct nxgl_rect_s *bounds,
- FAR void *arg)
+static void nximage_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
+ FAR const struct nxgl_point_s *pos,
+ FAR const struct nxgl_rect_s *bounds,
+ FAR void *arg)
{
/* Report the position */
@@ -218,8 +221,9 @@ static void nximage_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
****************************************************************************/
#ifdef CONFIG_NX_XYINPUT
-static void nximage_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
- uint8_t buttons, FAR void *arg)
+static void nximage_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
+ uint8_t buttons, FAR void *arg)
{
printf("nximage_mousein: hwnd=%p pos=(%d,%d) button=%02x\n",
hwnd, pos->x, pos->y, buttons);
@@ -235,16 +239,16 @@ static void nximage_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
****************************************************************************/
#ifdef CONFIG_NX_KBD
-static void nximage_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
- FAR void *arg)
+static void nximage_kbdin(NXWINDOW hwnd, uint8_t nch,
+ FAR const uint8_t *ch, FAR void *arg)
{
ginfo("hwnd=%p nch=%d\n", hwnd, nch);
- /* In this example, there is no keyboard so a keyboard event is not
- * expected.
- */
+ /* In this example, there is no keyboard so a keyboard event is not
+ * expected.
+ */
- printf("nximage_kbdin: Unexpected keyboard callback\n");
+ printf("nximage_kbdin: Unexpected keyboard callback\n");
}
#endif
@@ -288,9 +292,9 @@ void nximage_image(NXWINDOW hwnd)
{
/* Read input row(s) */
- nximage_blitrow(g_runs[0].run, &state);
+ nximage_blitrow(g_runs[0].run, &state);
#if NINPUT_ROWS > 1
- nximage_blitrow(g_runs[1].run, &state);
+ nximage_blitrow(g_runs[1].run, &state);
#endif
/* Output rows before averaging */
@@ -306,7 +310,8 @@ void nximage_image(NXWINDOW hwnd)
#if CONFIG_NX_NPLANES > 1
# warning "More logic is needed for the case where CONFIG_NX_PLANES > 1"
#endif
- ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t));
+ ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos,
+ SCALED_WIDTH * sizeof(nxgl_mxpixel_t));
if (ret < 0)
{
printf("nximage_image: nx_bitmapwindow failed: %d\n", errno);
@@ -348,7 +353,8 @@ void nximage_image(NXWINDOW hwnd)
#if CONFIG_NX_NPLANES > 1
# warning "More logic is needed for the case where CONFIG_NX_PLANES > 1"
#endif
- ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t));
+ ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos,
+ SCALED_WIDTH * sizeof(nxgl_mxpixel_t));
if (ret < 0)
{
printf("nximage_image: nx_bitmapwindow failed: %d\n", errno);
@@ -369,7 +375,8 @@ void nximage_image(NXWINDOW hwnd)
#if CONFIG_NX_NPLANES > 1
# warning "More logic is needed for the case where CONFIG_NX_PLANES > 1"
#endif
- ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos, SCALED_WIDTH*sizeof(nxgl_mxpixel_t));
+ ret = nx_bitmap((NXWINDOW)hwnd, &dest, src, &pos,
+ SCALED_WIDTH * sizeof(nxgl_mxpixel_t));
if (ret < 0)
{
printf("nximage_image: nx_bitmapwindow failed: %d\n", errno);
diff --git a/examples/nximage/nximage_main.c b/examples/nximage/nximage_main.c
index fd2beac0b..4d9648f0f 100644
--- a/examples/nximage/nximage_main.c
+++ b/examples/nximage/nximage_main.c
@@ -90,7 +90,7 @@ static inline int nximage_initialize(void)
ret = sched_setparam(0, ¶m);
if (ret < 0)
{
- printf("nximage_initialize: sched_setparam failed: %d\n" , ret);
+ printf("nximage_initialize: sched_setparam failed: %d\n", ret);
return ERROR;
}
@@ -99,7 +99,8 @@ static inline int nximage_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
- printf("nximage_initialize: Failed to start the NX server: %d\n", errno);
+ printf("nximage_initialize: Failed to start the NX server: %d\n",
+ errno);
return ERROR;
}
@@ -108,52 +109,53 @@ static inline int nximage_initialize(void)
g_nximage.hnx = nx_connect();
if (g_nximage.hnx)
{
- pthread_attr_t attr;
+ pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, g_nximage.hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
- nx_disconnect(g_nximage.hnx);
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, g_nximage.hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+ nx_disconnect(g_nximage.hnx);
+ return ERROR;
+ }
#endif
- /* Start a separate thread to listen for server events. This is probably
- * the least efficient way to do this, but it makes this example flow more
- * smoothly.
- */
-
- pthread_attr_init(&attr);
- param.sched_priority = CONFIG_EXAMPLES_NXIMAGE_LISTENERPRIO;
- pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXIMAGE_LISTENER_STACKSIZE);
-
- ret = pthread_create(&thread, &attr, nximage_listener, NULL);
- if (ret != 0)
- {
- printf("nximage_initialize: pthread_create failed: %d\n", ret);
- return ERROR;
- }
-
- /* Don't return until we are connected to the server */
-
- while (!g_nximage.connected)
- {
- /* Wait for the listener thread to wake us up when we really
- * are connected.
- */
-
- sem_wait(&g_nximage.eventsem);
- }
+ /* Start a separate thread to listen for server events. This is
+ * probably the least efficient way to do this, but it makes this
+ * example flow more smoothly.
+ */
+
+ pthread_attr_init(&attr);
+ param.sched_priority = CONFIG_EXAMPLES_NXIMAGE_LISTENERPRIO;
+ pthread_attr_setschedparam(&attr, ¶m);
+ pthread_attr_setstacksize(&attr,
+ CONFIG_EXAMPLES_NXIMAGE_LISTENER_STACKSIZE);
+
+ ret = pthread_create(&thread, &attr, nximage_listener, NULL);
+ if (ret != 0)
+ {
+ printf("nximage_initialize: pthread_create failed: %d\n", ret);
+ return ERROR;
+ }
+
+ /* Don't return until we are connected to the server */
+
+ while (!g_nximage.connected)
+ {
+ /* Wait for the listener thread to wake us up when we really
+ * are connected.
+ */
+
+ sem_wait(&g_nximage.eventsem);
+ }
}
else
{
@@ -194,7 +196,7 @@ int main(int argc, FAR char *argv[])
/* Set the background to the configured background color */
- color = nximage_bgcolor();
+ color = nximage_bgcolor();
printf("nximage_main: Set background color=%u\n", color);
ret = nx_setbgcolor(g_nximage.hnx, &color);
@@ -222,7 +224,8 @@ int main(int argc, FAR char *argv[])
sem_wait(&g_nximage.eventsem);
}
- printf("nximage_main: Screen resolution (%d,%d)\n", g_nximage.xres, g_nximage.yres);
+ printf("nximage_main: Screen resolution (%d,%d)\n",
+ g_nximage.xres, g_nximage.yres);
/* Now, put up the NuttX logo and wait a bit so that it visible. */
diff --git a/examples/nxlines/nxlines_main.c b/examples/nxlines/nxlines_main.c
index 85b75177e..f13294fd0 100644
--- a/examples/nxlines/nxlines_main.c
+++ b/examples/nxlines/nxlines_main.c
@@ -51,6 +51,7 @@
****************************************************************************/
/* Configuration ************************************************************/
+
/* If not specified, assume that the hardware supports one video plane */
#ifndef CONFIG_EXAMPLES_NXLINES_VPLANE
@@ -111,7 +112,7 @@ static inline int nxlines_initialize(void)
ret = sched_setparam(0, ¶m);
if (ret < 0)
{
- printf("nxlines_initialize: sched_setparam failed: %d\n" , ret);
+ printf("nxlines_initialize: sched_setparam failed: %d\n", ret);
return ERROR;
}
@@ -120,7 +121,8 @@ static inline int nxlines_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
- printf("nxlines_initialize: Failed to start the NX server: %d\n", errno);
+ printf("nxlines_initialize: Failed to start the NX server: %d\n",
+ errno);
return ERROR;
}
@@ -129,52 +131,53 @@ static inline int nxlines_initialize(void)
g_nxlines.hnx = nx_connect();
if (g_nxlines.hnx)
{
- pthread_attr_t attr;
+ pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, g_nxlines.hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
- nx_disconnect(g_nxlines.hnx);
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, g_nxlines.hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+ nx_disconnect(g_nxlines.hnx);
+ return ERROR;
+ }
#endif
- /* Start a separate thread to listen for server events. This is probably
- * the least efficient way to do this, but it makes this example flow more
- * smoothly.
- */
-
- pthread_attr_init(&attr);
- param.sched_priority = CONFIG_EXAMPLES_NXLINES_LISTENERPRIO;
- pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXLINES_LISTENER_STACKSIZE);
-
- ret = pthread_create(&thread, &attr, nxlines_listener, NULL);
- if (ret != 0)
- {
- printf("nxlines_initialize: pthread_create failed: %d\n", ret);
- return ERROR;
- }
-
- /* Don't return until we are connected to the server */
-
- while (!g_nxlines.connected)
- {
- /* Wait for the listener thread to wake us up when we really
- * are connected.
- */
-
- sem_wait(&g_nxlines.eventsem);
- }
+ /* Start a separate thread to listen for server events. This is
+ * probably the least efficient way to do this, but it makes this
+ * example flow more smoothly.
+ */
+
+ pthread_attr_init(&attr);
+ param.sched_priority = CONFIG_EXAMPLES_NXLINES_LISTENERPRIO;
+ pthread_attr_setschedparam(&attr, ¶m);
+ pthread_attr_setstacksize(&attr,
+ CONFIG_EXAMPLES_NXLINES_LISTENER_STACKSIZE);
+
+ ret = pthread_create(&thread, &attr, nxlines_listener, NULL);
+ if (ret != 0)
+ {
+ printf("nxlines_initialize: pthread_create failed: %d\n", ret);
+ return ERROR;
+ }
+
+ /* Don't return until we are connected to the server */
+
+ while (!g_nxlines.connected)
+ {
+ /* Wait for the listener thread to wake us up when we really
+ * are connected.
+ */
+
+ sem_wait(&g_nxlines.eventsem);
+ }
}
else
{
@@ -240,7 +243,8 @@ int main(int argc, FAR char *argv[])
sem_wait(&g_nxlines.eventsem);
}
- printf("nxlines_main: Screen resolution (%d,%d)\n", g_nxlines.xres, g_nxlines.yres);
+ printf("nxlines_main: Screen resolution (%d,%d)\n",
+ g_nxlines.xres, g_nxlines.yres);
/* Now, say perform the lines (these test does not return so the remaining
* logic is cosmetic).
diff --git a/examples/nxterm/nxterm_toolbar.c b/examples/nxterm/nxterm_toolbar.c
index 0fa7c0802..327a54057 100644
--- a/examples/nxterm/nxterm_toolbar.c
+++ b/examples/nxterm/nxterm_toolbar.c
@@ -54,12 +54,14 @@
static void nxtool_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
bool morem, FAR void *arg);
-static void nxtool_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxtool_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nxtool_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+static void nxtool_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
uint8_t buttons, FAR void *arg);
#endif
@@ -121,7 +123,8 @@ static void nxtool_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nxtool_position
****************************************************************************/
-static void nxtool_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxtool_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg)
diff --git a/examples/nxterm/nxterm_wndo.c b/examples/nxterm/nxterm_wndo.c
index c326e0449..ca88204ae 100644
--- a/examples/nxterm/nxterm_wndo.c
+++ b/examples/nxterm/nxterm_wndo.c
@@ -49,12 +49,14 @@
static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
bool morem, FAR void *arg);
-static void nxwndo_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxwndo_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg);
#ifdef CONFIG_NX_XYINPUT
-static void nxwndo_mousein(NXWINDOW hwnd, FAR const struct nxgl_point_s *pos,
+static void nxwndo_mousein(NXWINDOW hwnd,
+ FAR const struct nxgl_point_s *pos,
uint8_t buttons, FAR void *arg);
#endif
@@ -119,7 +121,9 @@ static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
}
else
{
- /* If the driver has not been opened, then just redraw the window color */
+ /* If the driver has not been opened, then just redraw the window
+ * color.
+ */
wcolor[0] = CONFIG_EXAMPLES_NXTERM_WCOLOR;
nxtk_fillwindow(hwnd, rect, wcolor);
@@ -130,7 +134,8 @@ static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nxwndo_position
****************************************************************************/
-static void nxwndo_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
+static void nxwndo_position(NXWINDOW hwnd,
+ FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg)
@@ -163,7 +168,8 @@ static void nxwndo_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
g_nxterm_vars.haveres = true;
sem_post(&g_nxterm_vars.eventsem);
- ginfo("Have xres=%d yres=%d\n", g_nxterm_vars.xres, g_nxterm_vars.yres);
+ ginfo("Have xres=%d yres=%d\n",
+ g_nxterm_vars.xres, g_nxterm_vars.yres);
}
}
diff --git a/examples/nxtext/nxtext_bkgd.c b/examples/nxtext/nxtext_bkgd.c
index 8eb55ba09..b0957bb7a 100644
--- a/examples/nxtext/nxtext_bkgd.c
+++ b/examples/nxtext/nxtext_bkgd.c
@@ -107,7 +107,8 @@ NXHANDLE g_bgwnd;
* Name: nxbg_redrawrect
****************************************************************************/
-static void nxbg_redrawrect(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect)
+static void nxbg_redrawrect(NXWINDOW hwnd,
+ FAR const struct nxgl_rect_s *rect)
{
int ret;
int i;
@@ -172,7 +173,9 @@ static void nxbg_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
st->wsize.w = size->w;
st->wsize.h = size->h;
- /* Save the window limits (these should be the same for all places and all windows */
+ /* Save the window limits (these should be the same for all places
+ * and all windows.
+ */
g_xres = bounds->pt2.x + 1;
g_yres = bounds->pt2.y + 1;
@@ -219,7 +222,8 @@ static void nxbg_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch,
* only.
****************************************************************************/
-static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight)
+static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom,
+ int lineheight)
{
FAR struct nxtext_bitmap_s *bm;
struct nxgl_rect_s rect;
@@ -227,10 +231,10 @@ static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight)
int ret;
int i;
- /* Move each row, one at a time. They could all be moved at once (by calling
- * nxbg_redrawrect), but the since the region is cleared, then re-written, the
- * effect would not be good. Below the region is also cleared and re-written,
- * however, in much smaller chunks.
+ /* Move each row, one at a time. They could all be moved at once (by
+ * calling nxbg_redrawrect), but since the region is cleared, then
+ * rewritten, the effect would not be good. Below the region is also
+ * cleared and rewritten, however, in much smaller chunks.
*/
rect.pt1.x = 0;
@@ -256,7 +260,8 @@ static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight)
for (i = 0; i < g_bgstate.nchars; i++)
{
bm = &g_bgstate.bm[i];
- if (bm->pos.y <= rect.pt2.y && bm->pos.y + g_bgstate.fheight >= rect.pt1.y)
+ if (bm->pos.y <= rect.pt2.y &&
+ bm->pos.y + g_bgstate.fheight >= rect.pt1.y)
{
nxtext_fillchar(hwnd, &rect, &g_bgstate, g_bghfont, bm);
}
@@ -266,7 +271,7 @@ static inline void nxbg_movedisplay(NXWINDOW hwnd, int bottom, int lineheight)
/* Finally, clear the bottom part of the display */
rect.pt1.y = bottom;
- rect.pt2.y = g_bgstate.wsize.h- 1;
+ rect.pt2.y = g_bgstate.wsize.h - 1;
ret = nx_fill(hwnd, &rect, g_bgstate.wcolor);
if (ret < 0)
@@ -296,13 +301,15 @@ static inline void nxbg_scroll(NXWINDOW hwnd, int lineheight)
{
/* Yes... Delete the character by moving all of the data */
- for (j = i; j < g_bgstate.nchars-1; j++)
+ for (j = i; j < g_bgstate.nchars - 1; j++)
{
- memcpy(&g_bgstate.bm[j], &g_bgstate.bm[j+1], sizeof(struct nxtext_bitmap_s));
+ memcpy(&g_bgstate.bm[j], &g_bgstate.bm[j + 1],
+ sizeof(struct nxtext_bitmap_s));
}
- /* Decrement the number of cached characters ('i' is not incremented
- * in this case because it already points to the next character)
+ /* Decrement the number of cached characters. 'i' is not
+ * incremented in this case because it already points to the next
+ * character.
*/
g_bgstate.nchars--;
diff --git a/examples/nxtext/nxtext_main.c b/examples/nxtext/nxtext_main.c
index d3d02956f..c749cd53a 100644
--- a/examples/nxtext/nxtext_main.c
+++ b/examples/nxtext/nxtext_main.c
@@ -60,6 +60,7 @@
****************************************************************************/
/* Configuration ************************************************************/
+
/* If not specified, assume that the hardware supports one video plane */
#ifndef CONFIG_EXAMPLES_NXTEXT_VPLANE
@@ -138,7 +139,10 @@ nxgl_coord_t g_yres;
bool b_haveresolution = false;
bool g_connected = false;
-sem_t g_semevent = {0};
+sem_t g_semevent =
+{
+ 0
+};
int g_exitcode = NXEXIT_SUCCESS;
@@ -162,7 +166,7 @@ static int nxtext_initialize(void)
ret = sched_setparam(0, ¶m);
if (ret < 0)
{
- printf("nxtext_initialize: sched_setparam failed: %d\n" , ret);
+ printf("nxtext_initialize: sched_setparam failed: %d\n", ret);
g_exitcode = NXEXIT_SCHEDSETPARAM;
return ERROR;
}
@@ -173,7 +177,8 @@ static int nxtext_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
- printf("nxtext_initialize: Failed to start the NX server: %d\n", errno);
+ printf("nxtext_initialize: Failed to start the NX server: %d\n",
+ errno);
g_exitcode = NXEXIT_SERVERSTART;
return ERROR;
}
@@ -188,24 +193,24 @@ static int nxtext_initialize(void)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, g_hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
- nx_disconnect(g_hnx);
- g_exitcode = NXEXIT_FBINITIALIZE;
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, g_hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+ nx_disconnect(g_hnx);
+ g_exitcode = NXEXIT_FBINITIALIZE;
+ return ERROR;
+ }
#endif
- /* Start a separate thread to listen for server events. This is probably
- * the least efficient way to do this, but it makes this example flow more
- * smoothly.
+ /* Start a separate thread to listen for server events. This is
+ * probably the least efficient way to do this, but it makes this
+ * example flow more smoothly.
*/
pthread_attr_init(&attr);
@@ -216,10 +221,10 @@ static int nxtext_initialize(void)
ret = pthread_create(&thread, &attr, nxtext_listener, NULL);
if (ret != 0)
{
- printf("nxtext_initialize: pthread_create failed: %d\n", ret);
+ printf("nxtext_initialize: pthread_create failed: %d\n", ret);
- g_exitcode = NXEXIT_PTHREADCREATE;
- return ERROR;
+ g_exitcode = NXEXIT_PTHREADCREATE;
+ return ERROR;
}
/* Don't return until we are connected to the server */
@@ -277,7 +282,8 @@ int main(int argc, FAR char *argv[])
g_bghfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_BGFONTID);
if (!g_bghfont)
{
- printf("nxtext_main: Failed to get background font handle: %d\n", errno);
+ printf("nxtext_main: Failed to get background font handle: %d\n",
+ errno);
g_exitcode = NXEXIT_FONTOPEN;
goto errout;
}
@@ -285,14 +291,16 @@ int main(int argc, FAR char *argv[])
g_puhfont = nxf_getfonthandle(CONFIG_EXAMPLES_NXTEXT_PUFONTID);
if (!g_puhfont)
{
- printf("nxtext_main: Failed to get pop-up font handle: %d\n", errno);
+ printf("nxtext_main: Failed to get pop-up font handle: %d\n",
+ errno);
g_exitcode = NXEXIT_FONTOPEN;
goto errout;
}
/* Set the background to the configured background color */
- printf("nxtext_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTEXT_BGCOLOR);
+ printf("nxtext_main: Set background color=%d\n",
+ CONFIG_EXAMPLES_NXTEXT_BGCOLOR);
color = CONFIG_EXAMPLES_NXTEXT_BGCOLOR;
ret = nx_setbgcolor(g_hnx, &color);
if (ret < 0)
@@ -328,7 +336,7 @@ int main(int argc, FAR char *argv[])
popcnt = 0;
bkgndx = 0;
- for (;;)
+ for (; ; )
{
/* Sleep for one second */
@@ -346,15 +354,18 @@ int main(int argc, FAR char *argv[])
hwnd = nxpu_open();
#ifdef CONFIG_NX_KBD
- /* Give keyboard input to the top window (which should be the pop-up) */
+ /* Give keyboard input to the top window (which should be the
+ * pop-up).
+ */
printf("nxtext_main: Send keyboard input: %s\n", g_pumsg);
- ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg), g_pumsg);
+ ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_pumsg),
+ g_pumsg);
if (ret < 0)
- {
- printf("nxtext_main: nx_kbdin failed: %d\n", errno);
- goto errout_with_hwnd;
- }
+ {
+ printf("nxtext_main: nx_kbdin failed: %d\n", errno);
+ goto errout_with_hwnd;
+ }
#endif
}
else if (popcnt == 5)
@@ -367,11 +378,12 @@ int main(int argc, FAR char *argv[])
}
/* Give another line of text to the background window. Force this
- * text to go the background by calling the background window interfaces
- * directly.
+ * text to the background by calling the background window
+ * interfaces directly.
*/
- nxbg_write(g_bgwnd, (FAR const uint8_t *)g_bgmsg[bkgndx], strlen(g_bgmsg[bkgndx]));
+ nxbg_write(g_bgwnd, (FAR const uint8_t *)g_bgmsg[bkgndx],
+ strlen(g_bgmsg[bkgndx]));
if (++bkgndx >= BGMSG_LINES)
{
bkgndx = 0;
@@ -386,13 +398,15 @@ errout_with_hwnd:
if (popcnt >= 3)
{
printf("nxtext_main: Close pop-up\n");
- nxpu_close(hwnd);
+ nxpu_close(hwnd);
}
-//errout_with_bkgd:
+ /* errout_with_bkgd: */
+
nx_releasebkgd(g_bgwnd);
errout_with_nx:
+
/* Disconnect from the server */
printf("nxtext_main: Disconnect from the server\n");
diff --git a/examples/nxtext/nxtext_putc.c b/examples/nxtext/nxtext_putc.c
index 384ae22bb..325132caf 100644
--- a/examples/nxtext/nxtext_putc.c
+++ b/examples/nxtext/nxtext_putc.c
@@ -95,6 +95,7 @@ static void nxtext_freeglyph(FAR struct nxtext_glyph_s *glyph)
{
free(glyph->bitmap);
}
+
memset(glyph, 0, sizeof(struct nxtext_glyph_s));
}
@@ -111,11 +112,11 @@ nxtext_allocglyph(FAR struct nxtext_state_s *st)
int i;
/* Search through the glyph cache looking for an unused glyph. Also, keep
- * track of the least used glyph as well. We need that if we have to replace
- * a glyph in the cache.
+ * track of the least used glyph as well. We need that if we have to
+ * replace a glyph in the cache.
*/
- for (i = 0; i < st->maxglyphs; i++)
+ for (i = 0; i < st->maxglyphs; i++)
{
/* Is this glyph in use? */
@@ -149,9 +150,9 @@ nxtext_allocglyph(FAR struct nxtext_state_s *st)
if (luusecnt > 1)
{
- uint8_t decr = luusecnt - 1;
+ uint8_t decr = luusecnt - 1;
- for (i = 0; i < st->maxglyphs; i++)
+ for (i = 0; i < st->maxglyphs; i++)
{
/* Is this glyph in use? */
@@ -180,7 +181,7 @@ nxtext_findglyph(FAR struct nxtext_state_s *st, uint8_t ch)
/* First, try to find the glyph in the cache of pre-rendered glyphs */
- for (i = 0; i < st->maxglyphs; i++)
+ for (i = 0; i < st->maxglyphs; i++)
{
FAR struct nxtext_glyph_s *glyph = &st->glyph[i];
if (glyph->usecnt > 0 && glyph->code == ch)
@@ -189,7 +190,7 @@ nxtext_findglyph(FAR struct nxtext_state_s *st, uint8_t ch)
if (glyph->usecnt < MAX_USECNT)
{
- glyph->usecnt++;
+ glyph->usecnt++;
}
/* And return the glyph that we found */
@@ -197,6 +198,7 @@ nxtext_findglyph(FAR struct nxtext_state_s *st, uint8_t ch)
return glyph;
}
}
+
return NULL;
}
@@ -248,13 +250,13 @@ nxtext_renderglyph(FAR struct nxtext_state_s *st,
/* Pack 1-bit pixels into a 2-bits */
pixel &= 0x01;
- pixel = (pixel) << 1 |pixel;
+ pixel = (pixel) << 1 | pixel;
# endif
# if CONFIG_EXAMPLES_NXTEXT_BPP < 4
/* Pack 2-bit pixels into a nibble */
pixel &= 0x03;
- pixel = (pixel) << 2 |pixel;
+ pixel = (pixel) << 2 | pixel;
# endif
/* Pack 4-bit nibbles into a byte */
@@ -292,7 +294,7 @@ nxtext_renderglyph(FAR struct nxtext_state_s *st,
/* Then render the glyph into the allocated memory */
- ret = RENDERER((FAR nxgl_mxpixel_t*)glyph->bitmap,
+ ret = RENDERER((FAR nxgl_mxpixel_t *)glyph->bitmap,
glyph->height, glyph->width, glyph->stride,
fbm, st->fcolor[0]);
if (ret < 0)
@@ -312,7 +314,8 @@ nxtext_renderglyph(FAR struct nxtext_state_s *st,
* Name: nxtext_fontsize
****************************************************************************/
-static int nxtext_fontsize(NXHANDLE hfont, uint8_t ch, FAR struct nxgl_size_s *size)
+static int nxtext_fontsize(NXHANDLE hfont, uint8_t ch,
+ FAR struct nxgl_size_s *size)
{
FAR const struct nx_fontbitmap_s *fbm;
@@ -379,37 +382,39 @@ nxtext_addchar(NXHANDLE hfont, FAR struct nxtext_state_s *st, uint8_t ch)
if (st->nchars < st->maxchars)
{
- /* Yes, setup the bitmap information */
+ /* Yes, setup the bitmap information */
- bm = &st->bm[st->nchars];
- bm->code = ch;
- bm->flags = 0;
- bm->pos.x = st->fpos.x;
- bm->pos.y = st->fpos.y;
+ bm = &st->bm[st->nchars];
+ bm->code = ch;
+ bm->flags = 0;
+ bm->pos.x = st->fpos.x;
+ bm->pos.y = st->fpos.y;
- /* Find (or create) the matching glyph */
+ /* Find (or create) the matching glyph */
- glyph = nxtext_getglyph(hfont, st, ch);
- if (!glyph)
- {
- /* No, there is no font for this code. Just mark this as a space. */
+ glyph = nxtext_getglyph(hfont, st, ch);
+ if (!glyph)
+ {
+ /* No, there is no font for this code. Just mark this as a
+ * space.
+ */
- bm->flags |= BMFLAGS_NOGLYPH;
+ bm->flags |= BMFLAGS_NOGLYPH;
- /* Set up the next character position */
+ /* Set up the next character position */
- st->fpos.x += st->spwidth;
- }
- else
- {
- /* Set up the next character position */
+ st->fpos.x += st->spwidth;
+ }
+ else
+ {
+ /* Set up the next character position */
- st->fpos.x += glyph->width;
- }
+ st->fpos.x += glyph->width;
+ }
- /* Success.. increment nchars to retain this character */
+ /* Success.. increment nchars to retain this character */
- st->nchars++;
+ st->nchars++;
}
return bm;
@@ -465,7 +470,8 @@ void nxtext_newline(FAR struct nxtext_state_s *st)
*
****************************************************************************/
-void nxtext_putc(NXWINDOW hwnd, FAR struct nxtext_state_s *st, NXHANDLE hfont, uint8_t ch)
+void nxtext_putc(NXWINDOW hwnd, FAR struct nxtext_state_s *st,
+ NXHANDLE hfont, uint8_t ch)
{
FAR const struct nxtext_bitmap_s *bm;
@@ -562,13 +568,13 @@ void nxtext_fillchar(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
/* Find (or create) the glyph that goes with this font */
- glyph = nxtext_getglyph(hfont, st, bm->code);
- if (!glyph)
- {
- /* Shouldn't happen */
+ glyph = nxtext_getglyph(hfont, st, bm->code);
+ if (!glyph)
+ {
+ /* Shouldn't happen */
- return;
- }
+ return;
+ }
/* Blit the font bitmap into the window */
diff --git a/examples/pwfb/pwfb_main.c b/examples/pwfb/pwfb_main.c
index 3b5993372..cd98a48e2 100644
--- a/examples/pwfb/pwfb_main.c
+++ b/examples/pwfb/pwfb_main.c
@@ -57,6 +57,8 @@
#include "pwfb_internal.h"
+#define ARROW1_CURSOR_IMAGE g_arrow1##Cursor
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -115,22 +117,22 @@ static bool pwfb_server_initialize(FAR struct pwfb_state_s *st)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, st->hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("pwfb_server_initialize: ERROR: "
- "boardctl(BOARDIOC_VNC_START) failed: %d\n",
- ret);
-
- nx_disconnect(st->hnx);
- g_exitcode = NXEXIT_FBINITIALIZE;
- return ERROR;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, st->hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("pwfb_server_initialize: ERROR: "
+ "boardctl(BOARDIOC_VNC_START) failed: %d\n",
+ ret);
+
+ nx_disconnect(st->hnx);
+ g_exitcode = NXEXIT_FBINITIALIZE;
+ return ERROR;
+ }
#endif
}
else
@@ -168,10 +170,10 @@ static bool pwfb_listener_initialize(FAR struct pwfb_state_s *st)
ret = pthread_create(&thread, &attr, pwfb_listener, st);
if (ret != 0)
{
- printf("pwfb_listener_initialize: ERROR: "
- "pthread_create failed: %d\n",
- ret);
- return false;
+ printf("pwfb_listener_initialize: ERROR: "
+ "pthread_create failed: %d\n",
+ ret);
+ return false;
}
/* Don't return until we are connected to the server */
@@ -340,8 +342,8 @@ static bool pwfb_putc(FAR struct pwfb_state_s *st,
/* Render the glyph into the window */
src = glyph->bitmap;
- ret = nxtk_bitmapwindow(wndo->hwnd, &bounds, &src,
- fpos, (unsigned int)glyph->stride);
+ ret = nxtk_bitmapwindow(wndo->hwnd, &bounds, &src,
+ fpos, (unsigned int)glyph->stride);
if (ret < 0)
{
printf("pwfb_putc: ERROR: "
@@ -510,8 +512,8 @@ static bool pwfb_configure_cursor(FAR struct pwfb_state_s *st,
st->cursor.state = PFWB_CURSOR_MOVING;
st->cursor.countdown = CURSOR_MOVING_DELAY;
st->cursor.blinktime = 0;
- st->cursor.xmax = itob16(st->xres - g_arrow1Cursor.size.w - 1);
- st->cursor.ymax = itob16(st->yres - g_arrow1Cursor.size.h - 1);
+ st->cursor.xmax = itob16(st->xres - ARROW1_CURSOR_IMAGE.size.w - 1);
+ st->cursor.ymax = itob16(st->yres - ARROW1_CURSOR_IMAGE.size.h - 1);
st->cursor.xpos = itob16(pos->x);
st->cursor.ypos = itob16(pos->y);
st->cursor.deltax = dtob16(deltax);
@@ -519,7 +521,7 @@ static bool pwfb_configure_cursor(FAR struct pwfb_state_s *st,
/* Set the cursor image */
- ret = nxcursor_setimage(st->hnx, &g_arrow1Cursor);
+ ret = nxcursor_setimage(st->hnx, &ARROW1_CURSOR_IMAGE);
if (ret < 0)
{
printf("pwfb_configure_cursor: ERROR: "
@@ -651,7 +653,8 @@ int main(int argc, FAR char *argv[])
pos.x = wstate.xres / 8;
pos.y = wstate.yres / 8;
- if (!pwfb_configure_window(&wstate, 0, &size, &pos, g_wndomsg1, 4.200, 4.285))
+ if (!pwfb_configure_window(&wstate, 0, &size, &pos, g_wndomsg1,
+ 4.200, 4.285))
{
printf("pwfb_main: ERROR: "
"pwfb_configure_window failed for window 1\n");
@@ -681,7 +684,8 @@ int main(int argc, FAR char *argv[])
pos.x = wstate.xres / 4;
pos.y = wstate.yres / 4;
- if (!pwfb_configure_window(&wstate, 1, &size, &pos, g_wndomsg2, -3.317, 5.0))
+ if (!pwfb_configure_window(&wstate, 1, &size, &pos, g_wndomsg2,
+ -3.317, 5.0))
{
printf("pwfb_main: ERROR: "
"pwfb_configure_window failed for window 2\n");
@@ -711,7 +715,8 @@ int main(int argc, FAR char *argv[])
pos.x = (3 * wstate.xres) / 8;
pos.y = (3 * wstate.yres) / 8;
- if (!pwfb_configure_window(&wstate, 2, &size, &pos, g_wndomsg3, 4.600, -3.852))
+ if (!pwfb_configure_window(&wstate, 2, &size, &pos, g_wndomsg3,
+ 4.600, -3.852))
{
printf("pwfb_main: ERROR: "
"pwfb_configure_window failed for window 2\n");
@@ -797,6 +802,7 @@ errout_with_hwnd1:
#endif
errout_with_fontcache:
+
/* Release the font cache */
nxf_cache_disconnect(wstate.wndo[0].fcache);
@@ -804,6 +810,7 @@ errout_with_fontcache:
nxf_cache_disconnect(wstate.wndo[2].fcache);
errout_with_nx:
+
/* Disconnect from the server */
printf("pwfb_main: Disconnect from the server\n");
diff --git a/examples/pwlines/pwlines_main.c b/examples/pwlines/pwlines_main.c
index 8d448cc11..53a2b3a53 100644
--- a/examples/pwlines/pwlines_main.c
+++ b/examples/pwlines/pwlines_main.c
@@ -94,21 +94,21 @@ static bool pwlines_server_initialize(FAR struct pwlines_state_s *st)
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
- struct boardioc_vncstart_s vnc =
- {
- 0, st->hnx
- };
-
- ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
- if (ret < 0)
- {
- printf("pwlines_server_initialize: ERROR: "
- "boardctl(BOARDIOC_VNC_START) failed: %d\n",
- ret);
-
- nx_disconnect(st->hnx);
- return false;
- }
+ struct boardioc_vncstart_s vnc =
+ {
+ 0, st->hnx
+ };
+
+ ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+ if (ret < 0)
+ {
+ printf("pwlines_server_initialize: ERROR: "
+ "boardctl(BOARDIOC_VNC_START) failed: %d\n",
+ ret);
+
+ nx_disconnect(st->hnx);
+ return false;
+ }
#endif
}
else
@@ -141,15 +141,16 @@ static bool pwlines_listener_initialize(FAR struct pwlines_state_s *st)
pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_PWLINES_LISTENER_PRIO;
pthread_attr_setschedparam(&attr, ¶m);
- pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_PWLINES_LISTENER_STACKSIZE);
+ pthread_attr_setstacksize(&attr,
+ CONFIG_EXAMPLES_PWLINES_LISTENER_STACKSIZE);
ret = pthread_create(&thread, &attr, pwlines_listener, st);
if (ret != 0)
{
- printf("pwlines_listener_initialize: ERROR: "
- "pthread_create failed: %d\n",
- ret);
- return false;
+ printf("pwlines_listener_initialize: ERROR: "
+ "pthread_create failed: %d\n",
+ ret);
+ return false;
}
/* Don't return until we are connected to the server */
@@ -193,7 +194,8 @@ static bool pwlines_state_initialize(FAR struct pwlines_state_s *st)
* Name: pwlines_configure_window
****************************************************************************/
-static bool pwlines_configure_window(FAR struct pwlines_state_s *st, int wndx,
+static bool pwlines_configure_window(FAR struct pwlines_state_s *st,
+ int wndx,
FAR struct nxgl_size_s *size,
FAR struct nxgl_point_s *pos,
double deltax, double deltay)
@@ -353,8 +355,9 @@ int main(int argc, FAR char *argv[])
printf("pwlines_main: Open window 1\n");
- wstate.wndo[0].hwnd = nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
- &g_pwlines_wncb, (FAR void *)&wstate);
+ wstate.wndo[0].hwnd =
+ nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
+ &g_pwlines_wncb, (FAR void *)&wstate);
if (wstate.wndo[0].hwnd == NULL)
{
printf("pwlines_main: ERROR: "
@@ -386,7 +389,8 @@ int main(int argc, FAR char *argv[])
pos.x = wstate.xres / 8;
pos.y = wstate.yres / 8;
- if (!pwlines_configure_window(&wstate, 0, &size, &pos, 4.200, 4.285))
+ if (!pwlines_configure_window(&wstate, 0, &size, &pos,
+ 4.200, 4.285))
{
printf("pwlines_main: ERROR: "
"pwlines_configure_window failed for window 1\n");
@@ -397,8 +401,9 @@ int main(int argc, FAR char *argv[])
printf("pwlines_main: Open window 2\n");
- wstate.wndo[1].hwnd = nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
- &g_pwlines_wncb, (FAR void *)&wstate);
+ wstate.wndo[1].hwnd =
+ nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
+ &g_pwlines_wncb, (FAR void *)&wstate);
if (wstate.wndo[1].hwnd == NULL)
{
printf("pwlines_main: ERROR: "
@@ -414,7 +419,8 @@ int main(int argc, FAR char *argv[])
pos.x = wstate.xres / 4;
pos.y = wstate.yres / 4;
- if (!pwlines_configure_window(&wstate, 1, &size, &pos, -3.317, 5.0))
+ if (!pwlines_configure_window(&wstate, 1, &size, &pos,
+ -3.317, 5.0))
{
printf("pwlines_main: ERROR: "
"pwlines_configure_window failed for window 2\n");
@@ -425,8 +431,9 @@ int main(int argc, FAR char *argv[])
printf("pwlines_main: Open window 3\n");
- wstate.wndo[2].hwnd = nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
- &g_pwlines_wncb, (FAR void *)&wstate);
+ wstate.wndo[2].hwnd =
+ nxtk_openwindow(wstate.hnx, NXBE_WINDOW_RAMBACKED,
+ &g_pwlines_wncb, (FAR void *)&wstate);
if (wstate.wndo[2].hwnd == NULL)
{
printf("pwlines_main: ERROR: "
@@ -442,7 +449,8 @@ int main(int argc, FAR char *argv[])
pos.x = (3 * wstate.xres) / 8;
pos.y = (3 * wstate.yres) / 8;
- if (!pwlines_configure_window(&wstate, 2, &size, &pos, 4.600, -3.852))
+ if (!pwlines_configure_window(&wstate, 2, &size, &pos,
+ 4.600, -3.852))
{
printf("pwlines_main: ERROR: "
"pwlines_configure_window failed for window 2\n");
@@ -512,6 +520,7 @@ errout_with_hwnd1:
}
errout_with_nx:
+
/* Disconnect from the server */
printf("pwlines_main: Disconnect from the server\n");
diff --git a/examples/qencoder/qe_main.c b/examples/qencoder/qe_main.c
index 504db260d..23e529802 100644
--- a/examples/qencoder/qe_main.c
+++ b/examples/qencoder/qe_main.c
@@ -307,11 +307,14 @@ int main(int argc, FAR char *argv[])
if (g_qeexample.use_qeindex)
{
- ret = ioctl(fd, QEIOC_GETINDEX, (unsigned long)((uintptr_t)&index));
+ ret = ioctl(fd, QEIOC_GETINDEX,
+ (unsigned long)((uintptr_t)&index));
if (ret < 0)
{
- printf("qe_main: ioctl(QEIOC_GETINDEX) failed: %d\n", errno);
- printf("Your MCU probably does not support this ioctl call.\n");
+ printf("qe_main: ioctl(QEIOC_GETINDEX) failed: %d\n",
+ errno);
+ printf("Your MCU probably does not support this ioctl "
+ "call.\n");
printf("Consider using this example without the -i option.\n");
exitval = EXIT_FAILURE;
goto errout_with_dev;
@@ -321,13 +324,17 @@ int main(int argc, FAR char *argv[])
else
{
- printf("qe_main: %3d. pos: %" PRIi32 ", last index: %" PRIi32 ", hit indexes: %" \
- PRIi16 "\n", nloops + 1, index.qenc_pos, index.indx_pos, index.indx_cnt);
+ printf("qe_main: %3d. pos: %" PRIi32 ", "
+ "last index: %" PRIi32 ", "
+ "hit indexes: %" PRIi16 "\n",
+ nloops + 1, index.qenc_pos, index.indx_pos,
+ index.indx_cnt);
}
}
else
{
- ret = ioctl(fd, QEIOC_POSITION, (unsigned long)((uintptr_t)&position));
+ ret = ioctl(fd, QEIOC_POSITION,
+ (unsigned long)((uintptr_t)&position));
if (ret < 0)
{
printf("qe_main: ioctl(QEIOC_POSITION) failed: %d\n", errno);
diff --git a/fsutils/flash_eraseall/flash_eraseall.c b/fsutils/flash_eraseall/flash_eraseall.c
index f7462c152..fda7b7e04 100644
--- a/fsutils/flash_eraseall/flash_eraseall.c
+++ b/fsutils/flash_eraseall/flash_eraseall.c
@@ -71,13 +71,14 @@ int flash_eraseall(FAR const char *driver)
if (ret < 0)
{
errcode = errno;
- ferr("ERROR: MTD ioctl(%04x) failed: %d\n", MTDIOC_BULKERASE, errcode);
+ ferr("ERROR: MTD ioctl(%04x) failed: %d\n",
+ MTDIOC_BULKERASE, errcode);
ret = -errcode;
}
/* Close the block driver */
- close(fd);
+ close(fd);
}
return ret;
diff --git a/graphics/tiff/tiff_addstrip.c b/graphics/tiff/tiff_addstrip.c
index 5db952088..965152eac 100644
--- a/graphics/tiff/tiff_addstrip.c
+++ b/graphics/tiff/tiff_addstrip.c
@@ -65,13 +65,15 @@
* tiff_initialize().
*
* Input Parameters:
- * info - A pointer to the caller allocated parameter passing/TIFF state instance.
+ * info - A pointer to the caller allocated parameter passing/TIFF
+ * state instance.
* buffer - A buffer containing a single row of data.
*
* Returned Value:
* Zero (OK) on success. A negated errno value on failure.
*
****************************************************************************/
+
int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
{
#ifdef CONFIG_DEBUG_GRAPHICS
@@ -100,9 +102,9 @@ int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
/* Convert RGB565 to RGB888 */
rgb565 = *src++;
- *dest++ = (rgb565 >> (11-3)) & 0xf8; /* Move bits 11-15 to 3-7 */
- *dest++ = (rgb565 >> ( 5-2)) & 0xfc; /* Move bits 5-10 to 2-7 */
- *dest++ = (rgb565 << ( 3)) & 0xf8; /* Move bits 0- 4 to 3-7 */
+ *dest++ = (rgb565 >> (11 - 3)) & 0xf8; /* Move bits 11-15 to 3-7 */
+ *dest++ = (rgb565 >> (5 - 2)) & 0xfc; /* Move bits 5-10 to 2-7 */
+ *dest++ = (rgb565 << 3) & 0xf8; /* Move bits 0- 4 to 3-7 */
/* Update the byte count */
@@ -113,7 +115,7 @@ int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
/* Flush the conversion buffer to tmpfile2 when it becomes full */
- if (nbytes > (info->iosize-3))
+ if (nbytes > (info->iosize - 3))
{
ret = tiff_write(info->tmp2fd, info->iobuffer, nbytes);
if (ret < 0)
@@ -134,6 +136,7 @@ int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
#ifdef CONFIG_DEBUG_GRAPHICS
DEBUGASSERT(ntotal == info->bps);
#endif
+
return ret;
}
@@ -150,7 +153,8 @@ int tiff_convstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
* tiff_initialize().
*
* Input Parameters:
- * info - A pointer to the caller allocated parameter passing/TIFF state instance.
+ * info - A pointer to the caller allocated parameter passing/TIFF
+ * state instance.
* buffer - A buffer containing a single row of data.
*
* Returned Value:
@@ -172,7 +176,9 @@ int tiff_addstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
ret = tiff_convstrip(info, strip);
}
- /* For other formats, it is a simple write using the number of bytes per strip */
+ /* For other formats, it is a simple write using the number of bytes per
+ * strip.
+ */
else
{
@@ -191,6 +197,7 @@ int tiff_addstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
{
goto errout;
}
+
info->outsize += 4;
ret = tiff_putint32(info->tmp1fd, info->tmp2size);
@@ -198,6 +205,7 @@ int tiff_addstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
{
goto errout;
}
+
info->tmp1size += 4;
/* Increment the size of tmp2file. */
@@ -212,14 +220,17 @@ int tiff_addstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip)
ret = (int)newsize;
goto errout;
}
+
info->tmp2size = (size_t)newsize;
/* Increment the number of strips in the TIFF file */
info->nstrips++;
+
return OK;
errout:
+
tiff_abort(info);
return ret;
}
diff --git a/graphics/tiff/tiff_initialize.c b/graphics/tiff/tiff_initialize.c
index 263f650cf..2c4f5921a 100644
--- a/graphics/tiff/tiff_initialize.c
+++ b/graphics/tiff/tiff_initialize.c
@@ -41,6 +41,7 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
+
/* Bi-level Images
*
* Offset Description Contents/Notes
@@ -50,13 +51,18 @@
* 8 [2 bytes padding]
* IFD: 10 Number of Directory Entries 13
* 12 NewSubfileType
- * 24 ImageWidth Number of columns is a user parameter
- * 36 ImageLength Number of rows is a user parameter
- * 48 Compression Hard-coded no compression (for now)
+ * 24 ImageWidth Number of columns is a user
+ * parameter
+ * 36 ImageLength Number of rows is a user
+ * parameter
+ * 48 Compression Hard-coded no compression
+ * (for now)
* 60 PhotometricInterpretation Value is a user parameter
- * 72 StripOffsets Offset and count determined as strips added
+ * 72 StripOffsets Offset and count determined
+ * as strips added
* 84 RowsPerStrip Value is a user parameter
- * 96 StripByteCounts Offset and count determined as strips added
+ * 96 StripByteCounts Offset and count determined
+ * as strips added
* 108 XResolution Value is a user parameter
* 120 YResolution Value is a user parameter
* 132 Resolution Unit Hard-coded to "inches"
@@ -67,8 +73,10 @@
* Values:
* 172 XResolution Hard-coded to 300/1
* 180 YResolution Hard-coded to 300/1
- * 188 "NuttX" Length = 6 (including NUL terminator)
- * 194 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL terminator)
+ * 188 "NuttX" Length = 6 (including NUL
+ * terminator)
+ * 194 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL
+ * terminator)
* 214 [2 bytes padding]
* 216 StripByteCounts Beginning of strip byte counts
* xxx StripOffsets Beginning of strip offsets
@@ -76,7 +84,7 @@
* xxx Data for strips Beginning of strip data
*/
-#define TIFF_IFD_OFFSET (SIZEOF_TIFF_HEADER+2)
+#define TIFF_IFD_OFFSET (SIZEOF_TIFF_HEADER + 2)
#define TIFF_BILEV_NIFDENTRIES 13
#define TIFF_BILEV_STRIPIFDOFFS 72
@@ -102,14 +110,19 @@
* 8 [2 bytes padding]
* IFD: 10 Number of Directory Entries 14
* 12 NewSubfileType
- * 24 ImageWidth Number of columns is a user parameter
- * 36 ImageLength Number of rows is a user parameter
+ * 24 ImageWidth Number of columns is a user
+ * parameter
+ * 36 ImageLength Number of rows is a user
+ * parameter
* 48 BitsPerSample
- * 60 Compression Hard-coded no compression (for now)
+ * 60 Compression Hard-coded no compression
+ * (for now)
* 72 PhotometricInterpretation Value is a user parameter
- * 84 StripOffsets Offset and count determined as strips added
+ * 84 StripOffsets Offset and count determined
+ * as strips added
* 96 RowsPerStrip Value is a user parameter
- * 108 StripByteCounts Offset and count determined as strips added
+ * 108 StripByteCounts Offset and count determined
+ * as strips added
* 120 XResolution Value is a user parameter
* 132 YResolution Value is a user parameter
* 144 Resolution Unit Hard-coded to "inches"
@@ -120,8 +133,10 @@
* Values:
* 184 XResolution Hard-coded to 300/1
* 192 YResolution Hard-coded to 300/1
- * 200 "NuttX" Length = 6 (including NUL terminator)
- * 206 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL terminator)
+ * 200 "NuttX" Length = 6 (including NUL
+ * terminator)
+ * 206 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL
+ * terminator)
* 226 [2 bytes padding]
* 228 StripByteCounts Beginning of strip byte counts
* xxx StripOffsets Beginning of strip offsets
@@ -148,15 +163,20 @@
* 8 [2 bytes padding]
* IFD: 10 Number of Directory Entries 15
* 12 NewSubfileType
- * 24 ImageWidth Number of columns is a user parameter
- * 36 ImageLength Number of rows is a user parameter
+ * 24 ImageWidth Number of columns is a user
+ * parameter
+ * 36 ImageLength Number of rows is a user
+ * parameter
* 48 BitsPerSample 8, 8, 8
- * 60 Compression Hard-coded no compression (for now)
+ * 60 Compression Hard-coded no compression
+ * (for now)
* 72 PhotometricInterpretation Value is a user parameter
- * 84 StripOffsets Offset and count determined as strips added
+ * 84 StripOffsets Offset and count determined
+ * as strips added
* 96 SamplesPerPixel Hard-coded to 3
* 108 RowsPerStrip Value is a user parameter
- * 120 StripByteCounts Offset and count determined as strips added
+ * 120 StripByteCounts Offset and count determined
+ * as strips added
* 132 XResolution Value is a user parameter
* 144 YResolution Value is a user parameter
* 156 Resolution Unit Hard-coded to "inches"
@@ -169,8 +189,10 @@
* 204 YResolution Hard-coded to 300/1
* 212 BitsPerSample 8, 8, 8
* 218 [2 bytes padding]
- * 220 "NuttX" Length = 6 (including NUL terminator)
- * 226 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL terminator)
+ * 220 "NuttX" Length = 6 (including NUL
+ * terminator)
+ * 226 "YYYY:MM:DD HH:MM:SS" Length = 20 (including NUL
+ * terminator)
* 246 [2 bytes padding]
* 248 StripByteCounts Beginning of strip byte counts
* xxx StripOffsets Beginning of strip offsets
@@ -189,8 +211,12 @@
#define TIFF_RGB_DATEOFFSET 226
#define TIFF_RGB_STRIPBCOFFSET 248
-/* Debug *******************************************************************/
-/* CONFIG_DEBUG_TIFFOFFSETS may be defined (along with CONFIG_DEBUG_FEATURES and
+/****************************************************************************
+ * Debug
+ ****************************************************************************/
+
+/* CONFIG_DEBUG_TIFFOFFSETS may be defined (along with CONFIG_DEBUG_FEATURES
+ * and
* CONFIG_DEBUG_GRAPHICS) in order to verify the pre-determined TIFF file
* offsets.
*/
@@ -200,11 +226,11 @@
#endif
#ifdef CONFIG_DEBUG_TIFFOFFSETS
-# define tiff_offset(o,l) (o) += (l)
-# define tiff_checkoffs(o,x) DEBUGASSERT((o) == (x))
+# define tiff_offset(o, l) (o) += (l)
+# define tiff_checkoffs(o, x) DEBUGASSERT((o) == (x))
#else
-# define tiff_offset(o,l)
-# define tiff_checkoffs(o,x)
+# define tiff_offset(o, l)
+# define tiff_checkoffs(o, x)
#endif
/****************************************************************************
@@ -408,7 +434,7 @@ static int tiff_datetime(FAR char *timbuf, unsigned int buflen)
/* Break the current time up into the format needed by strftime */
- gmtime_r((FAR const time_t*)&ts.tv_sec, &tm);
+ gmtime_r((FAR const time_t *)&ts.tv_sec, &tm);
/* Convert the current time to TIFF format */
@@ -427,7 +453,8 @@ static int tiff_datetime(FAR char *timbuf, unsigned int buflen)
* Setup to create a new TIFF file.
*
* Input Parameters:
- * info - A pointer to the caller allocated parameter passing/TIFF state instance.
+ * info - A pointer to the caller allocated parameter passing/TIFF state
+ * instance.
*
* Returned Value:
* Zero (OK) on success. A negated errno value on failure.
@@ -447,7 +474,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
/* Open all output files */
- info->outfd = open(info->outfile, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ info->outfd = open(info->outfile, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (info->outfd < 0)
{
gerr("ERROR: Failed to open %s for reading/writing: %d\n",
@@ -455,7 +482,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
goto errout;
}
- info->tmp1fd = open(info->tmpfile1, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ info->tmp1fd = open(info->tmpfile1, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (info->tmp1fd < 0)
{
gerr("ERROR: Failed to open %s for reading/writing: %d\n",
@@ -463,7 +490,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
goto errout;
}
- info->tmp2fd = open(info->tmpfile2, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ info->tmp2fd = open(info->tmpfile2, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (info->tmp2fd < 0)
{
gerr("ERROR: Failed to open %s for reading/writing: %d\n",
@@ -505,7 +532,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
case FB_FMT_RGB24: /* BPP=24 R=8, G=8, B=8 */
info->filefmt = &g_rgbinfo; /* RGB file image file info */
info->imgflags = IMGFLAGS_FMT_RGB24; /* Bit encoded image characteristics */
- info->bps = 3 *info->pps; /* Bytes per strip */
+ info->bps = 3 * info->pps; /* Bytes per strip */
break;
default:
@@ -526,6 +553,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, TIFF_IFD_OFFSET);
/* Write the Number of directory entries
@@ -538,6 +566,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, 2);
/* Write the NewSubfileType IFD entry
@@ -545,11 +574,13 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* All formats: Offset 12 NewSubfileType
*/
- ret = tiff_putifdentry16(info, IFD_TAG_NEWSUBFILETYPE, IFD_FIELD_LONG, 1, 0);
+ ret = tiff_putifdentry16(info, IFD_TAG_NEWSUBFILETYPE,
+ IFD_FIELD_LONG, 1, 0);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write ImageWidth and ImageLength
@@ -558,17 +589,20 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* 36 ImageLength Number of rows is a user parameter
*/
- ret = tiff_putifdentry16(info, IFD_TAG_IMAGEWIDTH, IFD_FIELD_SHORT, 1, info->imgwidth);
+ ret = tiff_putifdentry16(info, IFD_TAG_IMAGEWIDTH,
+ IFD_FIELD_SHORT, 1, info->imgwidth);
if (ret == OK)
{
- ret= tiff_putifdentry16(info, IFD_TAG_IMAGELENGTH, IFD_FIELD_SHORT, 1, info->imgheight);
+ ret = tiff_putifdentry16(info, IFD_TAG_IMAGELENGTH,
+ IFD_FIELD_SHORT, 1, info->imgheight);
}
if (ret < 0)
{
goto errout;
}
- tiff_offset(offset, 2*SIZEOF_IFD_ENTRY);
+
+ tiff_offset(offset, 2 * SIZEOF_IFD_ENTRY);
/* Write BitsPerSample
*
@@ -589,20 +623,24 @@ int tiff_initialize(FAR struct tiff_info_s *info)
val16 = 4;
}
- ret = tiff_putifdentry16(info, IFD_TAG_BITSPERSAMPLE, IFD_FIELD_SHORT, 1, val16);
+ ret = tiff_putifdentry16(info, IFD_TAG_BITSPERSAMPLE,
+ IFD_FIELD_SHORT, 1, val16);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
}
else if (IMGFLAGS_ISRGB(info->imgflags))
{
- ret = tiff_putifdentry(info, IFD_TAG_BITSPERSAMPLE, IFD_FIELD_SHORT, 3, TIFF_RGB_BPSOFFSET);
+ ret = tiff_putifdentry(info, IFD_TAG_BITSPERSAMPLE,
+ IFD_FIELD_SHORT, 3, TIFF_RGB_BPSOFFSET);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
}
@@ -613,11 +651,13 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 60 " " " " "" " " " " " "
*/
- ret = tiff_putifdentry16(info, IFD_TAG_COMPRESSION, IFD_FIELD_SHORT, 1, TAG_COMP_NONE);
+ ret = tiff_putifdentry16(info, IFD_TAG_COMPRESSION,
+ IFD_FIELD_SHORT, 1, TAG_COMP_NONE);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write PhotometricInterpretation:
@@ -641,6 +681,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write StripOffsets:
@@ -656,6 +697,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write SamplesPerPixel
@@ -667,11 +709,13 @@ int tiff_initialize(FAR struct tiff_info_s *info)
if (IMGFLAGS_ISRGB(info->imgflags))
{
- ret = tiff_putifdentry16(info, IFD_TAG_SAMPLESPERPIXEL, IFD_FIELD_SHORT, 1, 3);
+ ret = tiff_putifdentry16(info, IFD_TAG_SAMPLESPERPIXEL,
+ IFD_FIELD_SHORT, 1, 3);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
}
@@ -682,26 +726,33 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 108 Value is a user parameter
*/
- ret = tiff_putifdentry16(info, IFD_TAG_ROWSPERSTRIP, IFD_FIELD_SHORT, 1, info->rps);
+ ret = tiff_putifdentry16(info, IFD_TAG_ROWSPERSTRIP,
+ IFD_FIELD_SHORT, 1, info->rps);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write StripByteCounts:
*
- * Bi-level Images: Offset 96 Count determined as strips added, Value offset = 216
- * Greyscale: Offset 108 Count determined as strips added, Value offset = 228
- * RGB: Offset 120 Count determined as strips added, Value offset = 248
+ * Bi-level Images: Offset 96 Count determined as strips added, Value
+ * offset = 216
+ * Greyscale: Offset 108 Count determined as strips added, Value
+ * offset = 228
+ * RGB: Offset 120 Count determined as strips added, Value
+ * offset = 248
*/
tiff_checkoffs(offset, info->filefmt->sbcifdoffset);
- ret = tiff_putifdentry(info, IFD_TAG_STRIPCOUNTS, IFD_FIELD_LONG, 0, info->filefmt->sbcoffset);
+ ret = tiff_putifdentry(info, IFD_TAG_STRIPCOUNTS,
+ IFD_FIELD_LONG, 0, info->filefmt->sbcoffset);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write XResolution and YResolution:
@@ -711,17 +762,22 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 132 and 144, Values are a user parameters
*/
- ret = tiff_putifdentry(info, IFD_TAG_XRESOLUTION, IFD_FIELD_RATIONAL, 1, info->filefmt->xresoffset);
+ ret = tiff_putifdentry(info, IFD_TAG_XRESOLUTION,
+ IFD_FIELD_RATIONAL, 1,
+ info->filefmt->xresoffset);
if (ret == OK)
{
- ret = tiff_putifdentry(info, IFD_TAG_YRESOLUTION, IFD_FIELD_RATIONAL, 1, info->filefmt->yresoffset);
+ ret = tiff_putifdentry(info, IFD_TAG_YRESOLUTION,
+ IFD_FIELD_RATIONAL, 1,
+ info->filefmt->yresoffset);
}
if (ret < 0)
{
goto errout;
}
- tiff_offset(offset, 2*SIZEOF_IFD_ENTRY);
+
+ tiff_offset(offset, 2 * SIZEOF_IFD_ENTRY);
/* Write ResolutionUnit:
*
@@ -730,11 +786,13 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 156, Hard-coded to "inches"
*/
- ret = tiff_putifdentry16(info, IFD_TAG_RESUNIT, IFD_FIELD_SHORT, 1, TAG_RESUNIT_INCH);
+ ret = tiff_putifdentry16(info, IFD_TAG_RESUNIT,
+ IFD_FIELD_SHORT, 1, TAG_RESUNIT_INCH);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write Software:
@@ -744,11 +802,14 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 168 Count, Hard-coded "NuttX"
*/
- ret = tiff_putifdentry(info, IFD_TAG_SOFTWARE, IFD_FIELD_ASCII, TIFF_SOFTWARE_STRLEN, info->filefmt->swoffset);
+ ret = tiff_putifdentry(info, IFD_TAG_SOFTWARE,
+ IFD_FIELD_ASCII, TIFF_SOFTWARE_STRLEN,
+ info->filefmt->swoffset);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write DateTime:
@@ -758,11 +819,14 @@ int tiff_initialize(FAR struct tiff_info_s *info)
* RGB: Offset 180 Count, Format "YYYY:MM:DD HH:MM:SS"
*/
- ret = tiff_putifdentry(info, IFD_TAG_DATETIME, IFD_FIELD_ASCII, TIFF_DATETIME_STRLEN, info->filefmt->dateoffset);
+ ret = tiff_putifdentry(info, IFD_TAG_DATETIME,
+ IFD_FIELD_ASCII, TIFF_DATETIME_STRLEN,
+ info->filefmt->dateoffset);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, SIZEOF_IFD_ENTRY);
/* Write Next IFD Offset and 2 bytes of padding:
@@ -780,6 +844,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, 4);
/* Now we begin the value section of the file */
@@ -807,6 +872,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, 8);
tiff_checkoffs(offset, info->filefmt->yresoffset);
@@ -820,6 +886,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, 8);
/* Write RGB BitsPerSample Data:
@@ -837,6 +904,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
tiff_putint16(info->outfd, 8);
tiff_putint16(info->outfd, 8);
tiff_putint16(info->outfd, 0);
+
tiff_offset(offset, 8);
}
@@ -849,11 +917,13 @@ int tiff_initialize(FAR struct tiff_info_s *info)
*/
tiff_checkoffs(offset, info->filefmt->swoffset);
- ret = tiff_putstring(info->outfd, TIFF_SOFTWARE_STRING, TIFF_SOFTWARE_STRLEN);
+ ret = tiff_putstring(info->outfd, TIFF_SOFTWARE_STRING,
+ TIFF_SOFTWARE_STRLEN);
if (ret < 0)
{
goto errout;
}
+
tiff_offset(offset, TIFF_SOFTWARE_STRLEN);
/* Write the DateTime string:
@@ -876,6 +946,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, TIFF_DATETIME_STRLEN);
/* Add two bytes of padding */
@@ -885,6 +956,7 @@ int tiff_initialize(FAR struct tiff_info_s *info)
{
goto errout;
}
+
tiff_offset(offset, 2);
/* And that should do it! */
diff --git a/graphics/tiff/tiff_utils.c b/graphics/tiff/tiff_utils.c
index 17e72689b..12aa4bb8e 100644
--- a/graphics/tiff/tiff_utils.c
+++ b/graphics/tiff/tiff_utils.c
@@ -93,10 +93,10 @@ void tiff_put32(FAR uint8_t *dest, uint32_t value)
{
#ifdef CONFIG_ENDIAN_BIG
tiff_put16(dest, (uint16_t)(value >> 16));
- tiff_put16(dest+2, (uint16_t)(value & 0xffff));
+ tiff_put16(dest + 2, (uint16_t)(value & 0xffff));
#else
tiff_put16(dest, (uint16_t)(value & 0xffff));
- tiff_put16(dest+2, (uint16_t)(value >> 16));
+ tiff_put16(dest + 2, (uint16_t)(value >> 16));
#endif
}
@@ -112,11 +112,10 @@ uint16_t tiff_get16(FAR uint8_t *src)
uint32_t tiff_get32(FAR uint8_t *src)
{
#ifdef CONFIG_ENDIAN_BIG
- return (uint32_t)tiff_get16(src) << 16 | (uint32_t)tiff_get16(src+2);
+ return (uint32_t)tiff_get16(src) << 16 | (uint32_t)tiff_get16(src + 2);
#else
- return (uint32_t)tiff_get16(src+2) << 16 | (uint32_t)tiff_get16(src);
+ return (uint32_t)tiff_get16(src + 2) << 16 | (uint32_t)tiff_get16(src);
#endif
-
}
/****************************************************************************
@@ -153,7 +152,7 @@ ssize_t tiff_read(int fd, FAR void *buffer, size_t count)
* (ntotal).
*/
- nbytes = read(fd, buffer, count-ntotal);
+ nbytes = read(fd, buffer, count - ntotal);
/* Check for an error */
@@ -166,22 +165,26 @@ ssize_t tiff_read(int fd, FAR void *buffer, size_t count)
errval = errno;
if (errval != EINTR)
{
- /* Other errors are bad news and we will break out with an error */
+ /* Other errors are bad news and we will break out with an
+ * error.
+ */
return -errval;
}
}
- /* Zero is a special case and means that the end of file was encountered. */
+ /* Zero is a special case and means that the end of file was
+ * encountered.
+ */
else if (nbytes == 0)
{
break;
}
- /* What if read returns some number of bytes other than the requested number?
- * This probably means that the end-of-file will be encountered the next time
- * that we call read().
+ /* What if read returns some number of bytes other than the requested
+ * number? This probably means that the end-of-file will be
+ * encountered the next time that we call read().
*/
else
@@ -236,13 +239,17 @@ int tiff_write(int fd, FAR const void *buffer, size_t count)
errval = errno;
if (errval != EINTR)
{
- /* Other errors are bad news and we will break out with an error */
+ /* Other errors are bad news and we will break out with an
+ * error.
+ */
return -errval;
}
}
- /* What if write returns some number of bytes other than the requested number? */
+ /* What if write returns some number of bytes other than the requested
+ * number?
+ */
else
{
@@ -326,7 +333,7 @@ int tiff_putstring(int fd, FAR const char *string, int len)
#ifdef CONFIG_DEBUG_GRAPHICS
int actual = strlen(string);
- DEBUGASSERT(len = actual+1);
+ DEBUGASSERT(len == actual + 1);
#endif
return tiff_write(fd, string, len);
}
@@ -362,7 +369,9 @@ ssize_t tiff_wordalign(int fd, size_t size)
{
return (ssize_t)ret;
}
+
size += nbytes;
}
+
return size;
}
diff --git a/system/nxcamera/nxcamera.c b/system/nxcamera/nxcamera.c
index d698b9e20..b8f5d41aa 100644
--- a/system/nxcamera/nxcamera.c
+++ b/system/nxcamera/nxcamera.c
@@ -52,6 +52,10 @@
#ifdef CONFIG_LIBYUV
# include <libyuv.h>
+
+# define CONVERT_TO_ARGB ConvertToARGB
+# define CONVERT_FROM_I420 ConvertFromI420
+# define CONVERT_TO_I420 ConvertToI420
#endif
/****************************************************************************
@@ -91,38 +95,38 @@ static int show_image(FAR struct nxcamera_s *pcam, FAR v4l2_buffer_t *buf)
#ifdef CONFIG_LIBYUV
if (pcam->display_vinfo.fmt == FB_FMT_RGB32)
{
- return ConvertToARGB(pcam->bufs[buf->index],
- pcam->buf_sizes[buf->index],
- pcam->display_pinfo.fbmem,
- pcam->display_pinfo.stride,
- 0,
- 0,
- pcam->fmt.fmt.pix.width,
- pcam->fmt.fmt.pix.height,
- pcam->fmt.fmt.pix.width,
- pcam->fmt.fmt.pix.height,
- 0,
- pcam->fmt.fmt.pix.pixelformat);
+ return CONVERT_TO_ARGB(pcam->bufs[buf->index],
+ pcam->buf_sizes[buf->index],
+ pcam->display_pinfo.fbmem,
+ pcam->display_pinfo.stride,
+ 0,
+ 0,
+ pcam->fmt.fmt.pix.width,
+ pcam->fmt.fmt.pix.height,
+ pcam->fmt.fmt.pix.width,
+ pcam->fmt.fmt.pix.height,
+ 0,
+ pcam->fmt.fmt.pix.pixelformat);
}
else if (pcam->display_vinfo.fmt == FB_FMT_RGB16_565)
{
if (pcam->fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YUV420)
{
- return ConvertFromI420(pcam->bufs[buf->index],
- pcam->fmt.fmt.pix.width,
- &pcam->bufs[buf->index][
- pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height],
- pcam->fmt.fmt.pix.width / 2,
- &pcam->bufs[buf->index][
- pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height * 5 / 4],
- pcam->fmt.fmt.pix.width / 2,
- pcam->display_pinfo.fbmem,
- pcam->display_pinfo.stride,
- pcam->fmt.fmt.pix.width,
- pcam->fmt.fmt.pix.height,
- V4L2_PIX_FMT_RGB565);
+ return CONVERT_FROM_I420(pcam->bufs[buf->index],
+ pcam->fmt.fmt.pix.width,
+ &pcam->bufs[buf->index][
+ pcam->fmt.fmt.pix.width *
+ pcam->fmt.fmt.pix.height],
+ pcam->fmt.fmt.pix.width / 2,
+ &pcam->bufs[buf->index][
+ pcam->fmt.fmt.pix.width *
+ pcam->fmt.fmt.pix.height * 5 / 4],
+ pcam->fmt.fmt.pix.width / 2,
+ pcam->display_pinfo.fbmem,
+ pcam->display_pinfo.stride,
+ pcam->fmt.fmt.pix.width,
+ pcam->fmt.fmt.pix.height,
+ V4L2_PIX_FMT_RGB565);
}
else
{
@@ -134,42 +138,42 @@ static int show_image(FAR struct nxcamera_s *pcam, FAR v4l2_buffer_t *buf)
return -ENOMEM;
}
- ret = ConvertToI420(pcam->bufs[buf->index],
- pcam->buf_sizes[buf->index],
- dst,
- pcam->fmt.fmt.pix.width,
- &dst[pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height],
- pcam->fmt.fmt.pix.width / 2,
- &dst[pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height * 5 / 4],
- pcam->fmt.fmt.pix.width / 2,
- 0,
- 0,
- pcam->fmt.fmt.pix.width,
- pcam->fmt.fmt.pix.height,
- pcam->fmt.fmt.pix.width,
- pcam->fmt.fmt.pix.height,
- 0,
- pcam->fmt.fmt.pix.pixelformat);
- if (ret < 0)
- {
- goto err;
- }
-
- ret = ConvertFromI420(dst,
+ ret = CONVERT_TO_I420(pcam->bufs[buf->index],
+ pcam->buf_sizes[buf->index],
+ dst,
pcam->fmt.fmt.pix.width,
&dst[pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height],
+ pcam->fmt.fmt.pix.height],
pcam->fmt.fmt.pix.width / 2,
&dst[pcam->fmt.fmt.pix.width *
- pcam->fmt.fmt.pix.height * 5 / 4],
+ pcam->fmt.fmt.pix.height * 5 / 4],
pcam->fmt.fmt.pix.width / 2,
- pcam->display_pinfo.fbmem,
- pcam->display_pinfo.stride,
+ 0,
+ 0,
pcam->fmt.fmt.pix.width,
pcam->fmt.fmt.pix.height,
- V4L2_PIX_FMT_RGB565);
+ pcam->fmt.fmt.pix.width,
+ pcam->fmt.fmt.pix.height,
+ 0,
+ pcam->fmt.fmt.pix.pixelformat);
+ if (ret < 0)
+ {
+ goto err;
+ }
+
+ ret = CONVERT_FROM_I420(dst,
+ pcam->fmt.fmt.pix.width,
+ &dst[pcam->fmt.fmt.pix.width *
+ pcam->fmt.fmt.pix.height],
+ pcam->fmt.fmt.pix.width / 2,
+ &dst[pcam->fmt.fmt.pix.width *
+ pcam->fmt.fmt.pix.height * 5 / 4],
+ pcam->fmt.fmt.pix.width / 2,
+ pcam->display_pinfo.fbmem,
+ pcam->display_pinfo.stride,
+ pcam->fmt.fmt.pix.width,
+ pcam->fmt.fmt.pix.height,
+ V4L2_PIX_FMT_RGB565);
if (ret < 0)
{
goto err;