Patches 7-9 from Petteri Aimonen

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5366 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-11-17 13:50:59 +00:00
parent 39ce8b1fab
commit 43dda7996d
11 changed files with 164 additions and 11 deletions

View File

@ -3641,4 +3641,11 @@
window. From Petteri Aimonen. window. From Petteri Aimonen.
* nuttx/graphics/nxmu/nx_block.c: One more fixe to the NX block message * nuttx/graphics/nxmu/nx_block.c: One more fixe to the NX block message
logic from Petteri Aimonen. logic from Petteri Aimonen.
* include/nuttx/wqueue.h: Some basic definitions to support a user-
space work queue (someday in the future).
* graphics/nxmu: Add semaphores so buffers messages that send buffers
will block until the buffer data has been acted upon.
* graphics/nxmw: Extended the blocked messages to cover mouse movement
and redraw events. These will also cause problems if sent to a window
while it is closing.

View File

@ -100,6 +100,8 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_bitmap_s outmsg; struct nxsvrmsg_bitmap_s outmsg;
int i; int i;
int ret;
sem_t sem_done;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!wnd || !dest || !src || !origin) if (!wnd || !dest || !src || !origin)
@ -124,7 +126,32 @@ int nx_bitmap(NXWINDOW hwnd, FAR const struct nxgl_rect_s *dest,
outmsg.origin.y = origin->y; outmsg.origin.y = origin->y;
nxgl_rectcopy(&outmsg.dest, dest); nxgl_rectcopy(&outmsg.dest, dest);
/* Create a semaphore for tracking command completion */
outmsg.sem_done = &sem_done;
ret = sem_init(&sem_done, 0, 0);
if (ret != OK)
{
gdbg("sem_init failed: %d\n", errno);
return ret;
}
/* Forward the fill command to the server */ /* Forward the fill command to the server */
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s)); ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_bitmap_s));
/* Wait that the command is completed, so that caller can release the buffer. */
if (ret == OK)
{
ret = sem_wait(&sem_done);
}
/* Destroy the semaphore and return. */
sem_destroy(&sem_done);
return ret;
} }

View File

@ -98,6 +98,8 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
{ {
FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd; FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
struct nxsvrmsg_getrectangle_s outmsg; struct nxsvrmsg_getrectangle_s outmsg;
int ret;
sem_t sem_done;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!hwnd || !rect || !dest) if (!hwnd || !rect || !dest)
@ -118,7 +120,31 @@ int nx_getrectangle(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
nxgl_rectcopy(&outmsg.rect, rect); nxgl_rectcopy(&outmsg.rect, rect);
/* Create a semaphore for tracking command completion */
outmsg.sem_done = &sem_done;
ret = sem_init(&sem_done, 0, 0);
if (ret != OK)
{
gdbg("sem_init failed: %d\n", errno);
return ret;
}
/* Forward the fill command to the server */ /* Forward the fill command to the server */
return nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s)); ret = nxmu_sendwindow(wnd, &outmsg, sizeof(struct nxsvrmsg_getrectangle_s));
/* Wait that the command is completed, so that caller can release the buffer. */
if (ret == OK)
{
ret = sem_wait(&sem_done);
}
/* Destroy the semaphore and return. */
sem_destroy(&sem_done);
return ret;
} }

View File

@ -392,6 +392,7 @@ struct nxsvrmsg_getrectangle_s
unsigned int plane; /* The plane number to read */ unsigned int plane; /* The plane number to read */
FAR uint8_t *dest; /* Memory location in which to store the graphics data */ FAR uint8_t *dest; /* Memory location in which to store the graphics data */
unsigned int deststride; /* Width of the destination memory in bytes */ unsigned int deststride; /* Width of the destination memory in bytes */
sem_t *sem_done; /* Semaphore to report when command is done. */
}; };
/* Fill a trapezoidal region in the window with a color */ /* Fill a trapezoidal region in the window with a color */
@ -425,6 +426,7 @@ struct nxsvrmsg_bitmap_s
FAR const void *src[CONFIG_NX_NPLANES]; /* The start of the source image. */ FAR const void *src[CONFIG_NX_NPLANES]; /* The start of the source image. */
struct nxgl_point_s origin; /* Offset into the source image data */ struct nxgl_point_s origin; /* Offset into the source image data */
unsigned int stride; /* The width of the full source image in pixels. */ unsigned int stride; /* The width of the full source image in pixels. */
sem_t *sem_done; /* Semaphore to report when command is done. */
}; };
/* Set the color of the background */ /* Set the color of the background */
@ -586,6 +588,25 @@ EXTERN int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
EXTERN int nxmu_sendclient(FAR struct nxfe_conn_s *conn, EXTERN int nxmu_sendclient(FAR struct nxfe_conn_s *conn,
FAR const void *msg, size_t msglen); FAR const void *msg, size_t msglen);
/****************************************************************************
* Name: nxmu_sendclientwindow
*
* Description:
* Send a message to the client at NX_CLIMSG_PRIO priority
*
* Input Parameters:
* wnd - A pointer to the back-end window structure
* msg - A pointer to the message to send
* msglen - The length of the message in bytes.
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
size_t msglen);
/**************************************************************************** /****************************************************************************
* Name: nxmu_openwindow * Name: nxmu_openwindow
* *

View File

@ -108,7 +108,7 @@ void nxmu_kbdin(FAR struct nxfe_state_s *fe, uint8_t nch, FAR uint8_t *ch)
outmsg->ch[i] = ch[i]; outmsg->ch[i] = ch[i];
} }
(void)nxmu_sendclient(fe->be.topwnd->conn, outmsg, size); (void)nxmu_sendclientwindow(fe->be.topwnd, outmsg, size);
free(outmsg); free(outmsg);
} }
} }

View File

@ -130,7 +130,7 @@ int nxmu_mousereport(struct nxbe_window_s *wnd)
outmsg.buttons = g_mbutton; outmsg.buttons = g_mbutton;
nxgl_vectsubtract(&outmsg.pos, &g_mpos, &wnd->bounds.pt1); nxgl_vectsubtract(&outmsg.pos, &g_mpos, &wnd->bounds.pt1);
return nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s)); return nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_mousein_s));
} }
} }
@ -202,7 +202,7 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
outmsg.buttons = g_mbutton; outmsg.buttons = g_mbutton;
nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1); nxgl_vectsubtract(&outmsg.pos, &g_mpos, &g_mwnd->bounds.pt1);
return nxmu_sendclient(g_mwnd->conn, &outmsg, sizeof(struct nxclimsg_mousein_s)); return nxmu_sendclientwindow(g_mwnd, &outmsg, sizeof(struct nxclimsg_mousein_s));
} }
/* Pick the window to receive the mouse event. Start with the top /* Pick the window to receive the mouse event. Start with the top

View File

@ -87,7 +87,7 @@ void nxfe_redrawreq(FAR struct nxbe_window_s *wnd, FAR const struct nxgl_rect_s
outmsg.more = false; outmsg.more = false;
nxgl_rectoffset(&outmsg.rect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y); nxgl_rectoffset(&outmsg.rect, rect, -wnd->bounds.pt1.x, -wnd->bounds.pt1.y);
(void)nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_redraw_s)); (void)nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_redraw_s));
} }

View File

@ -100,7 +100,7 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
/* And provide this to the client */ /* And provide this to the client */
ret = nxmu_sendclient(wnd->conn, &outmsg, sizeof(struct nxclimsg_newposition_s)); ret = nxmu_sendclientwindow(wnd, &outmsg, sizeof(struct nxclimsg_newposition_s));
if (ret < 0) if (ret < 0)
{ {
gdbg("nxmu_sendclient failed: %d\n", errno); gdbg("nxmu_sendclient failed: %d\n", errno);

View File

@ -112,3 +112,47 @@ int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
return ret; return ret;
} }
/****************************************************************************
* Name: nxmu_sendclientwindow
*
* Description:
* Send a message to the client at NX_CLIMSG_PRIO priority
*
* Input Parameters:
* wnd - A pointer to the back-end window structure
* msg - A pointer to the message to send
* msglen - The length of the message in bytes.
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
*
****************************************************************************/
int nxmu_sendclientwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
size_t msglen)
{
int ret = OK;
/* Sanity checking */
#ifdef CONFIG_DEBUG
if (!wnd || !wnd->conn)
{
errno = EINVAL;
return ERROR;
}
#endif
/* Ignore messages destined to a blocked window (no errors reported) */
if (!NXBE_ISBLOCKED(wnd))
{
/* Send the message to the server */
ret = nxmu_sendclient(wnd->conn, msg, msglen);
}
return ret;
}

View File

@ -451,6 +451,11 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
{ {
FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer; FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer;
nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride); nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride);
if (getmsg->sem_done)
{
sem_post(getmsg->sem_done);
}
} }
break; break;
@ -471,6 +476,11 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
{ {
FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer; FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer;
nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride); nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride);
if (bmpmsg->sem_done)
{
sem_post(bmpmsg->sem_done);
}
} }
break; break;

View File

@ -109,17 +109,35 @@
# endif # endif
#endif #endif
/* Work queue IDs (indices). These are both zero if there is only one work /* Work queue IDs (indices):
* queue. *
* Kernel Work Queues:
* HPWORK: This ID of the high priority work queue that should only be used for
* hi-priority, time-critical, driver bottom-half functions.
*
* LPWORK: This is the ID of the low priority work queue that can be used for any
* purpose. if CONFIG_SCHED_LPWORK is not defined, then there is only one kernel
* work queue and LPWORK == HPWORK.
*
* User Work Queue:
* USRWORK: CONFIG_NUTTX_KERNEL and CONFIG_SCHED_USRWORK are defined, then NuttX
* will also support a user-accessible work queue. Otherwise, USRWORK == LPWORK.
*/ */
#define HPWORK 0 #define HPWORK 0
#ifdef CONFIG_SCHED_LPWORK #ifdef CONFIG_SCHED_LPWORK
# define LPWORK 1 # define LPWORK (HPWORK+1)
#else #else
# define LPWORK HPWORK # define LPWORK HPWORK
#endif #endif
#if defined(CONFIG_NUTTX_KERNEL) && defined(CONFIG_SCHED_USRWORK)
# warning "Feature not implemented"
# define USRWORK (LPWORK+1)
#else
# define USRWORK LPWORK
#endif
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/