#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <assert.h>
#include <sys/mman.h>
#include <linux/stddef.h>
* @ctx: a pointer to g2d_context structure.
* @cmd: command data.
* @value: value data.
+ *
+ * The caller has to make sure that the commands buffers have enough space
+ * left to hold the command. Use g2d_check_space() to ensure this.
*/
-static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
+static void g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
unsigned long value)
{
switch (cmd & ~(G2D_BUF_USERPTR)) {
case DST_PLANE2_BASE_ADDR_REG:
case PAT_BASE_ADDR_REG:
case MASK_BASE_ADDR_REG:
- if (ctx->cmd_buf_nr >= G2D_MAX_GEM_CMD_NR) {
- fprintf(stderr, "Overflow cmd_gem size.\n");
- return -EINVAL;
- }
+ assert(ctx->cmd_buf_nr < G2D_MAX_GEM_CMD_NR);
ctx->cmd_buf[ctx->cmd_buf_nr].offset = cmd;
ctx->cmd_buf[ctx->cmd_buf_nr].data = value;
ctx->cmd_buf_nr++;
break;
default:
- if (ctx->cmd_nr >= G2D_MAX_CMD_NR) {
- fprintf(stderr, "Overflow cmd size.\n");
- return -EINVAL;
- }
+ assert(ctx->cmd_nr < G2D_MAX_CMD_NR);
ctx->cmd[ctx->cmd_nr].offset = cmd;
ctx->cmd[ctx->cmd_nr].data = value;
ctx->cmd_nr++;
break;
}
-
- return 0;
}
/*