diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-09-26 21:57:44 +0200 | 
|---|---|---|
| committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2013-09-26 23:49:27 +0200 | 
| commit | c4df9505cb1a6af6c1e7b12246b3d02f9e64597d (patch) | |
| tree | 869f41a59ab7dc8054a8a887ddd52f673688e0c3 /src | |
| parent | 8762373646cfea5549dc80b36b79e0b8a2e43207 (diff) | |
Print more detailed v4l parse error messages
The following errors usually resulted in the same 'Unable to parse
format' message:
- syntax error in format description
- the requested pixel code isn't supported
Add more detailed error messages to give the user a clue what is going
wrong.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 2 | ||||
| -rw-r--r-- | src/v4l2subdev.c | 51 | 
2 files changed, 38 insertions, 15 deletions
| @@ -417,7 +417,7 @@ int main(int argc, char **argv)  		ret = v4l2_subdev_parse_setup_formats(media,  						      media_opts.formats);  		if (ret) { -			printf("Unable to parse format: %s (%d)\n", +			printf("Unable to setup formats: %s (%d)\n",  			       strerror(-ret), -ret);  			goto out;  		} diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c index 1370962..60655af 100644 --- a/src/v4l2subdev.c +++ b/src/v4l2subdev.c @@ -228,7 +228,8 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,  	return 0;  } -static int v4l2_subdev_parse_format(struct v4l2_mbus_framefmt *format, +static int v4l2_subdev_parse_format(struct media_device *media, +				    struct v4l2_mbus_framefmt *format,  				    const char *p, char **endp)  {  	enum v4l2_mbus_pixelcode code; @@ -244,13 +245,17 @@ static int v4l2_subdev_parse_format(struct v4l2_mbus_framefmt *format,  	     *end != '/' && *end != ' ' && *end != '\0'; ++end);  	code = v4l2_subdev_string_to_pixelcode(p, end - p); -	if (code == (enum v4l2_mbus_pixelcode)-1) +	if (code == (enum v4l2_mbus_pixelcode)-1) { +		media_dbg(media, "Invalid pixel code '%.*s'\n", end - p, p);  		return -EINVAL; +	}  	p = end + 1;  	width = strtoul(p, &end, 10); -	if (*end != 'x') +	if (*end != 'x') { +		media_dbg(media, "Expected 'x'\n");  		return -EINVAL; +	}  	p = end + 1;  	height = strtoul(p, &end, 10); @@ -264,29 +269,40 @@ static int v4l2_subdev_parse_format(struct v4l2_mbus_framefmt *format,  	return 0;  } -static int v4l2_subdev_parse_rectangle( -	struct v4l2_rect *r, const char *p, char **endp) +static int v4l2_subdev_parse_rectangle(struct media_device *media, +				       struct v4l2_rect *r, const char *p, +				       char **endp)  {  	char *end; -	if (*p++ != '(') +	if (*p++ != '(') { +		media_dbg(media, "Expected '('\n");  		return -EINVAL; +	}  	r->left = strtoul(p, &end, 10); -	if (*end != ',') +	if (*end != ',') { +		media_dbg(media, "Expected ','\n");  		return -EINVAL; +	}  	p = end + 1;  	r->top = strtoul(p, &end, 10); -	if (*end++ != ')') +	if (*end++ != ')') { +		media_dbg(media, "Expected ')'\n");  		return -EINVAL; -	if (*end != '/') +	} +	if (*end != '/') { +		media_dbg(media, "Expected '/'\n");  		return -EINVAL; +	}  	p = end + 1;  	r->width = strtoul(p, &end, 10); -	if (*end != 'x') +	if (*end != 'x') { +		media_dbg(media, "Expected 'x'\n");  		return -EINVAL; +	}  	p = end + 1;  	r->height = strtoul(p, &end, 10); @@ -295,7 +311,8 @@ static int v4l2_subdev_parse_rectangle(  	return 0;  } -static int v4l2_subdev_parse_frame_interval(struct v4l2_fract *interval, +static int v4l2_subdev_parse_frame_interval(struct media_device *media, +					    struct v4l2_fract *interval,  					    const char *p, char **endp)  {  	char *end; @@ -305,8 +322,10 @@ static int v4l2_subdev_parse_frame_interval(struct v4l2_fract *interval,  	interval->numerator = strtoul(p, &end, 10);  	for (p = end; isspace(*p); ++p); -	if (*p++ != '/') +	if (*p++ != '/') { +		media_dbg(media, "Expected '/'\n");  		return -EINVAL; +	}  	for (; isspace(*p); ++p);  	interval->denominator = strtoul(p, &end, 10); @@ -348,8 +367,10 @@ static struct media_pad *v4l2_subdev_parse_pad_format(  		return NULL;  	for (p = end; isspace(*p); ++p); -	if (*p++ != '[') +	if (*p++ != '[') { +		media_dbg(media, "Expected '['\n");  		return NULL; +	}  	for (first = true; ; first = false) {  		for (; isspace(*p); p++); @@ -401,8 +422,10 @@ static struct media_pad *v4l2_subdev_parse_pad_format(  		break;  	} -	if (*p != ']') +	if (*p != ']') { +		media_dbg(media, "Expected ']'\n");  		return NULL; +	}  	*endp = (char *)p + 1;  	return pad; | 
