xref: /rk3399_rockchip-uboot/drivers/video/videomodes.c (revision a5dbdc81ea70daa04e49eb0004a0441131a029c6)
1352d2591SJean-Christophe PLAGNIOL-VILLARD /*
2352d2591SJean-Christophe PLAGNIOL-VILLARD  * (C) Copyright 2004
3352d2591SJean-Christophe PLAGNIOL-VILLARD  * Pierre Aubert, Staubli Faverges , <p.aubert@staubli.com>
4*a5dbdc81STimur Tabi  * Copyright 2011 Freescale Semiconductor, Inc.
5352d2591SJean-Christophe PLAGNIOL-VILLARD  *
6352d2591SJean-Christophe PLAGNIOL-VILLARD  * See file CREDITS for list of people who contributed to this
7352d2591SJean-Christophe PLAGNIOL-VILLARD  * project.
8352d2591SJean-Christophe PLAGNIOL-VILLARD  *
9352d2591SJean-Christophe PLAGNIOL-VILLARD  * This program is free software; you can redistribute it and/or
10352d2591SJean-Christophe PLAGNIOL-VILLARD  * modify it under the terms of the GNU General Public License as
11352d2591SJean-Christophe PLAGNIOL-VILLARD  * published by the Free Software Foundation; either version 2 of
12352d2591SJean-Christophe PLAGNIOL-VILLARD  * the License, or (at your option) any later version.
13352d2591SJean-Christophe PLAGNIOL-VILLARD  *
14352d2591SJean-Christophe PLAGNIOL-VILLARD  * This program is distributed in the hope that it will be useful,
15352d2591SJean-Christophe PLAGNIOL-VILLARD  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16352d2591SJean-Christophe PLAGNIOL-VILLARD  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
17352d2591SJean-Christophe PLAGNIOL-VILLARD  * GNU General Public License for more details.
18352d2591SJean-Christophe PLAGNIOL-VILLARD  *
19352d2591SJean-Christophe PLAGNIOL-VILLARD  * You should have received a copy of the GNU General Public License
20352d2591SJean-Christophe PLAGNIOL-VILLARD  * along with this program; if not, write to the Free Software
21352d2591SJean-Christophe PLAGNIOL-VILLARD  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22352d2591SJean-Christophe PLAGNIOL-VILLARD  * MA 02111-1307 USA
23352d2591SJean-Christophe PLAGNIOL-VILLARD  */
24352d2591SJean-Christophe PLAGNIOL-VILLARD 
25352d2591SJean-Christophe PLAGNIOL-VILLARD /************************************************************************
26352d2591SJean-Christophe PLAGNIOL-VILLARD   Get Parameters for the video mode:
276d0f6bcfSJean-Christophe PLAGNIOL-VILLARD   The default video mode can be defined in CONFIG_SYS_DEFAULT_VIDEO_MODE.
28352d2591SJean-Christophe PLAGNIOL-VILLARD   If undefined, default video mode is set to 0x301
29352d2591SJean-Christophe PLAGNIOL-VILLARD   Parameters can be set via the variable "videomode" in the environment.
30352d2591SJean-Christophe PLAGNIOL-VILLARD   2 diferent ways are possible:
31352d2591SJean-Christophe PLAGNIOL-VILLARD   "videomode=301"   - 301 is a hexadecimal number describing the VESA
32352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode. Following modes are implemented:
33352d2591SJean-Christophe PLAGNIOL-VILLARD 
34352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Colors	640x480 800x600 1024x768 1152x864 1280x1024
35352d2591SJean-Christophe PLAGNIOL-VILLARD 		     --------+---------------------------------------------
36352d2591SJean-Christophe PLAGNIOL-VILLARD 		      8 bits |	0x301	0x303	 0x305	  0x161	    0x307
37352d2591SJean-Christophe PLAGNIOL-VILLARD 		     15 bits |	0x310	0x313	 0x316	  0x162	    0x319
38352d2591SJean-Christophe PLAGNIOL-VILLARD 		     16 bits |	0x311	0x314	 0x317	  0x163	    0x31A
39352d2591SJean-Christophe PLAGNIOL-VILLARD 		     24 bits |	0x312	0x315	 0x318	    ?	    0x31B
40352d2591SJean-Christophe PLAGNIOL-VILLARD 		     --------+---------------------------------------------
41352d2591SJean-Christophe PLAGNIOL-VILLARD   "videomode=bootargs"
42352d2591SJean-Christophe PLAGNIOL-VILLARD 		   - the parameters are parsed from the bootargs.
43352d2591SJean-Christophe PLAGNIOL-VILLARD 		      The format is "NAME:VALUE,NAME:VALUE" etc.
44352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Ex.:
45352d2591SJean-Christophe PLAGNIOL-VILLARD 		      "bootargs=video=ctfb:x:800,y:600,depth:16,pclk:25000"
46352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Parameters not included in the list will be taken from
47352d2591SJean-Christophe PLAGNIOL-VILLARD 		      the default mode, which is one of the following:
48352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:0  640x480x24
49352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:1  800x600x16
50352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:2  1024x768x8
51352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:3  960x720x24
52352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:4  1152x864x16
53352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:5  1280x1024x8
54352d2591SJean-Christophe PLAGNIOL-VILLARD 
55352d2591SJean-Christophe PLAGNIOL-VILLARD 		      if "mode" is not provided within the parameter list,
56352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:0 is assumed.
57352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Following parameters are supported:
58352d2591SJean-Christophe PLAGNIOL-VILLARD 		      x	      xres = visible resolution horizontal
59352d2591SJean-Christophe PLAGNIOL-VILLARD 		      y	      yres = visible resolution vertical
60352d2591SJean-Christophe PLAGNIOL-VILLARD 		      pclk    pixelclocks in pico sec
61352d2591SJean-Christophe PLAGNIOL-VILLARD 		      le      left_marging time from sync to picture in pixelclocks
62352d2591SJean-Christophe PLAGNIOL-VILLARD 		      ri      right_marging time from picture to sync in pixelclocks
63352d2591SJean-Christophe PLAGNIOL-VILLARD 		      up      upper_margin time from sync to picture
64352d2591SJean-Christophe PLAGNIOL-VILLARD 		      lo      lower_margin
65352d2591SJean-Christophe PLAGNIOL-VILLARD 		      hs      hsync_len length of horizontal sync
66352d2591SJean-Christophe PLAGNIOL-VILLARD 		      vs      vsync_len length of vertical sync
67352d2591SJean-Christophe PLAGNIOL-VILLARD 		      sync    see FB_SYNC_*
68352d2591SJean-Christophe PLAGNIOL-VILLARD 		      vmode   see FB_VMODE_*
69352d2591SJean-Christophe PLAGNIOL-VILLARD 		      depth   Color depth in bits per pixel
70352d2591SJean-Christophe PLAGNIOL-VILLARD 		      All other parameters in the variable bootargs are ignored.
71352d2591SJean-Christophe PLAGNIOL-VILLARD 		      It is also possible to set the parameters direct in the
72352d2591SJean-Christophe PLAGNIOL-VILLARD 		      variable "videomode", or in another variable i.e.
73352d2591SJean-Christophe PLAGNIOL-VILLARD 		      "myvideo" and setting the variable "videomode=myvideo"..
74352d2591SJean-Christophe PLAGNIOL-VILLARD ****************************************************************************/
75352d2591SJean-Christophe PLAGNIOL-VILLARD 
76352d2591SJean-Christophe PLAGNIOL-VILLARD #include <common.h>
77*a5dbdc81STimur Tabi #include <linux/ctype.h>
78*a5dbdc81STimur Tabi 
79352d2591SJean-Christophe PLAGNIOL-VILLARD #include "videomodes.h"
80352d2591SJean-Christophe PLAGNIOL-VILLARD 
81352d2591SJean-Christophe PLAGNIOL-VILLARD const struct ctfb_vesa_modes vesa_modes[VESA_MODES_COUNT] = {
82352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x301, RES_MODE_640x480, 8},
83352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x310, RES_MODE_640x480, 15},
84352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x311, RES_MODE_640x480, 16},
85352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x312, RES_MODE_640x480, 24},
86352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x303, RES_MODE_800x600, 8},
87352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x313, RES_MODE_800x600, 15},
88352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x314, RES_MODE_800x600, 16},
89352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x315, RES_MODE_800x600, 24},
90352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x305, RES_MODE_1024x768, 8},
91352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x316, RES_MODE_1024x768, 15},
92352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x317, RES_MODE_1024x768, 16},
93352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x318, RES_MODE_1024x768, 24},
94352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x161, RES_MODE_1152x864, 8},
95352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x162, RES_MODE_1152x864, 15},
96352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x163, RES_MODE_1152x864, 16},
97352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x307, RES_MODE_1280x1024, 8},
98352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x319, RES_MODE_1280x1024, 15},
99352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x31A, RES_MODE_1280x1024, 16},
100352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x31B, RES_MODE_1280x1024, 24},
101352d2591SJean-Christophe PLAGNIOL-VILLARD };
102352d2591SJean-Christophe PLAGNIOL-VILLARD const struct ctfb_res_modes res_mode_init[RES_MODES_COUNT] = {
103352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* x	 y pixclk   le	ri  up	lo   hs vs  s  vmode */
104352d2591SJean-Christophe PLAGNIOL-VILLARD 	{640, 480, 39721, 40, 24, 32, 11, 96, 2, 0, FB_VMODE_NONINTERLACED},
105352d2591SJean-Christophe PLAGNIOL-VILLARD 	{800, 600, 27778, 64, 24, 22, 1, 72, 2, 0, FB_VMODE_NONINTERLACED},
106352d2591SJean-Christophe PLAGNIOL-VILLARD 	{1024, 768, 15384, 168, 8, 29, 3, 144, 4, 0, FB_VMODE_NONINTERLACED},
107352d2591SJean-Christophe PLAGNIOL-VILLARD 	{960, 720, 13100, 160, 40, 32, 8, 80, 4, 0, FB_VMODE_NONINTERLACED},
108352d2591SJean-Christophe PLAGNIOL-VILLARD 	{1152, 864, 12004, 200, 64, 32, 16, 80, 4, 0, FB_VMODE_NONINTERLACED},
109352d2591SJean-Christophe PLAGNIOL-VILLARD 	{1280, 1024, 9090, 200, 48, 26, 1, 184, 3, 0, FB_VMODE_NONINTERLACED},
110352d2591SJean-Christophe PLAGNIOL-VILLARD };
111352d2591SJean-Christophe PLAGNIOL-VILLARD 
112352d2591SJean-Christophe PLAGNIOL-VILLARD /************************************************************************
113352d2591SJean-Christophe PLAGNIOL-VILLARD  * Get Parameters for the video mode:
114352d2591SJean-Christophe PLAGNIOL-VILLARD  */
115352d2591SJean-Christophe PLAGNIOL-VILLARD /*********************************************************************
116352d2591SJean-Christophe PLAGNIOL-VILLARD  * returns the length to the next seperator
117352d2591SJean-Christophe PLAGNIOL-VILLARD  */
118352d2591SJean-Christophe PLAGNIOL-VILLARD static int
119352d2591SJean-Christophe PLAGNIOL-VILLARD video_get_param_len (char *start, char sep)
120352d2591SJean-Christophe PLAGNIOL-VILLARD {
121352d2591SJean-Christophe PLAGNIOL-VILLARD 	int i = 0;
122352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((*start != 0) && (*start != sep)) {
123352d2591SJean-Christophe PLAGNIOL-VILLARD 		start++;
124352d2591SJean-Christophe PLAGNIOL-VILLARD 		i++;
125352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
126352d2591SJean-Christophe PLAGNIOL-VILLARD 	return i;
127352d2591SJean-Christophe PLAGNIOL-VILLARD }
128352d2591SJean-Christophe PLAGNIOL-VILLARD 
129352d2591SJean-Christophe PLAGNIOL-VILLARD static int
130352d2591SJean-Christophe PLAGNIOL-VILLARD video_search_param (char *start, char *param)
131352d2591SJean-Christophe PLAGNIOL-VILLARD {
132352d2591SJean-Christophe PLAGNIOL-VILLARD 	int len, totallen, i;
133352d2591SJean-Christophe PLAGNIOL-VILLARD 	char *p = start;
134352d2591SJean-Christophe PLAGNIOL-VILLARD 	len = strlen (param);
135352d2591SJean-Christophe PLAGNIOL-VILLARD 	totallen = len + strlen (start);
136352d2591SJean-Christophe PLAGNIOL-VILLARD 	for (i = 0; i < totallen; i++) {
137352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (strncmp (p++, param, len) == 0)
138352d2591SJean-Christophe PLAGNIOL-VILLARD 			return (i);
139352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
140352d2591SJean-Christophe PLAGNIOL-VILLARD 	return -1;
141352d2591SJean-Christophe PLAGNIOL-VILLARD }
142352d2591SJean-Christophe PLAGNIOL-VILLARD 
143352d2591SJean-Christophe PLAGNIOL-VILLARD /***************************************************************
144352d2591SJean-Christophe PLAGNIOL-VILLARD  * Get parameter via the environment as it is done for the
145352d2591SJean-Christophe PLAGNIOL-VILLARD  * linux kernel i.e:
146352d2591SJean-Christophe PLAGNIOL-VILLARD  * video=ctfb:x:800,xv:1280,y:600,yv:1024,depth:16,mode:0,pclk:25000,
147352d2591SJean-Christophe PLAGNIOL-VILLARD  *	 le:56,ri:48,up:26,lo:5,hs:152,vs:2,sync:0,vmode:0,accel:0
148352d2591SJean-Christophe PLAGNIOL-VILLARD  *
149352d2591SJean-Christophe PLAGNIOL-VILLARD  * penv is a pointer to the environment, containing the string, or the name of
150352d2591SJean-Christophe PLAGNIOL-VILLARD  * another environment variable. It could even be the term "bootargs"
151352d2591SJean-Christophe PLAGNIOL-VILLARD  */
152352d2591SJean-Christophe PLAGNIOL-VILLARD 
153352d2591SJean-Christophe PLAGNIOL-VILLARD #define GET_OPTION(name,var)				\
154352d2591SJean-Christophe PLAGNIOL-VILLARD 	if(strncmp(p,name,strlen(name))==0) {		\
155352d2591SJean-Christophe PLAGNIOL-VILLARD 		val_s=p+strlen(name);			\
156352d2591SJean-Christophe PLAGNIOL-VILLARD 		var=simple_strtoul(val_s, NULL, 10);	\
157352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
158352d2591SJean-Christophe PLAGNIOL-VILLARD 
159352d2591SJean-Christophe PLAGNIOL-VILLARD int video_get_params (struct ctfb_res_modes *pPar, char *penv)
160352d2591SJean-Christophe PLAGNIOL-VILLARD {
161352d2591SJean-Christophe PLAGNIOL-VILLARD 	char *p, *s, *val_s;
162352d2591SJean-Christophe PLAGNIOL-VILLARD 	int i = 0, t;
163352d2591SJean-Christophe PLAGNIOL-VILLARD 	int bpp;
164352d2591SJean-Christophe PLAGNIOL-VILLARD 	int mode;
165352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* first search for the environment containing the real param string */
166352d2591SJean-Christophe PLAGNIOL-VILLARD 	s = penv;
167352d2591SJean-Christophe PLAGNIOL-VILLARD 	if ((p = getenv (s)) != NULL) {
168352d2591SJean-Christophe PLAGNIOL-VILLARD 		s = p;
169352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
170352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* in case of the bootargs line, we have to start
171352d2591SJean-Christophe PLAGNIOL-VILLARD 	 * after "video=ctfb:"
172352d2591SJean-Christophe PLAGNIOL-VILLARD 	 */
173352d2591SJean-Christophe PLAGNIOL-VILLARD 	i = video_search_param (s, "video=ctfb:");
174352d2591SJean-Christophe PLAGNIOL-VILLARD 	if (i >= 0) {
175352d2591SJean-Christophe PLAGNIOL-VILLARD 		s += i;
176352d2591SJean-Christophe PLAGNIOL-VILLARD 		s += strlen ("video=ctfb:");
177352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
178352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* search for mode as a default value */
179352d2591SJean-Christophe PLAGNIOL-VILLARD 	p = s;
180352d2591SJean-Christophe PLAGNIOL-VILLARD 	t = 0;
181352d2591SJean-Christophe PLAGNIOL-VILLARD 	mode = 0;		/* default */
182352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((i = video_get_param_len (p, ',')) != 0) {
183352d2591SJean-Christophe PLAGNIOL-VILLARD 		GET_OPTION ("mode:", mode)
184352d2591SJean-Christophe PLAGNIOL-VILLARD 			p += i;
185352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (*p != 0)
186352d2591SJean-Christophe PLAGNIOL-VILLARD 			p++;	/* skip ',' */
187352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
188352d2591SJean-Christophe PLAGNIOL-VILLARD 	if (mode >= RES_MODES_COUNT)
189352d2591SJean-Christophe PLAGNIOL-VILLARD 		mode = 0;
190352d2591SJean-Christophe PLAGNIOL-VILLARD 	*pPar = res_mode_init[mode];	/* copy default values */
191352d2591SJean-Christophe PLAGNIOL-VILLARD 	bpp = 24 - ((mode % 3) * 8);
192352d2591SJean-Christophe PLAGNIOL-VILLARD 	p = s;			/* restart */
193352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((i = video_get_param_len (p, ',')) != 0) {
194352d2591SJean-Christophe PLAGNIOL-VILLARD 		GET_OPTION ("x:", pPar->xres)
195352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("y:", pPar->yres)
196352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("le:", pPar->left_margin)
197352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("ri:", pPar->right_margin)
198352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("up:", pPar->upper_margin)
199352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("lo:", pPar->lower_margin)
200352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("hs:", pPar->hsync_len)
201352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("vs:", pPar->vsync_len)
202352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("sync:", pPar->sync)
203352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("vmode:", pPar->vmode)
204352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("pclk:", pPar->pixclock)
205352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("depth:", bpp)
206352d2591SJean-Christophe PLAGNIOL-VILLARD 			p += i;
207352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (*p != 0)
208352d2591SJean-Christophe PLAGNIOL-VILLARD 			p++;	/* skip ',' */
209352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
210352d2591SJean-Christophe PLAGNIOL-VILLARD 	return bpp;
211352d2591SJean-Christophe PLAGNIOL-VILLARD }
212*a5dbdc81STimur Tabi 
213*a5dbdc81STimur Tabi /*
214*a5dbdc81STimur Tabi  * Parse the 'video-mode' environment variable
215*a5dbdc81STimur Tabi  *
216*a5dbdc81STimur Tabi  * Example: "video-mode=fslfb:1280x1024-32@60,monitor=dvi".  See
217*a5dbdc81STimur Tabi  * doc/README.video for more information on how to set the variable.
218*a5dbdc81STimur Tabi  *
219*a5dbdc81STimur Tabi  * @xres: returned value of X-resolution
220*a5dbdc81STimur Tabi  * @yres: returned value of Y-resolution
221*a5dbdc81STimur Tabi  * @depth: returned value of color depth
222*a5dbdc81STimur Tabi  * @freq: returned value of monitor frequency
223*a5dbdc81STimur Tabi  * @options: pointer to any remaining options, or NULL
224*a5dbdc81STimur Tabi  *
225*a5dbdc81STimur Tabi  * Returns 1 if valid values were found, 0 otherwise
226*a5dbdc81STimur Tabi  */
227*a5dbdc81STimur Tabi int video_get_video_mode(unsigned int *xres, unsigned int *yres,
228*a5dbdc81STimur Tabi 	unsigned int *depth, unsigned int *freq, const char **options)
229*a5dbdc81STimur Tabi {
230*a5dbdc81STimur Tabi 	char *p = getenv("video-mode");
231*a5dbdc81STimur Tabi 	if (!p)
232*a5dbdc81STimur Tabi 		return 0;
233*a5dbdc81STimur Tabi 
234*a5dbdc81STimur Tabi 	/* Skip over the driver name, which we don't care about. */
235*a5dbdc81STimur Tabi 	p = strchr(p, ':');
236*a5dbdc81STimur Tabi 	if (!p)
237*a5dbdc81STimur Tabi 		return 0;
238*a5dbdc81STimur Tabi 
239*a5dbdc81STimur Tabi 	/* Get the X-resolution*/
240*a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
241*a5dbdc81STimur Tabi 		p++;
242*a5dbdc81STimur Tabi 	*xres = simple_strtoul(p, &p, 10);
243*a5dbdc81STimur Tabi 	if (!*xres)
244*a5dbdc81STimur Tabi 		return 0;
245*a5dbdc81STimur Tabi 
246*a5dbdc81STimur Tabi 	/* Get the Y-resolution */
247*a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
248*a5dbdc81STimur Tabi 		p++;
249*a5dbdc81STimur Tabi 	*yres = simple_strtoul(p, &p, 10);
250*a5dbdc81STimur Tabi 	if (!*yres)
251*a5dbdc81STimur Tabi 		return 0;
252*a5dbdc81STimur Tabi 
253*a5dbdc81STimur Tabi 	/* Get the depth */
254*a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
255*a5dbdc81STimur Tabi 		p++;
256*a5dbdc81STimur Tabi 	*depth = simple_strtoul(p, &p, 10);
257*a5dbdc81STimur Tabi 	if (!*depth)
258*a5dbdc81STimur Tabi 		return 0;
259*a5dbdc81STimur Tabi 
260*a5dbdc81STimur Tabi 	/* Get the frequency */
261*a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
262*a5dbdc81STimur Tabi 		p++;
263*a5dbdc81STimur Tabi 	*freq = simple_strtoul(p, &p, 10);
264*a5dbdc81STimur Tabi 	if (!*freq)
265*a5dbdc81STimur Tabi 		return 0;
266*a5dbdc81STimur Tabi 
267*a5dbdc81STimur Tabi 	/* Find the extra options, if any */
268*a5dbdc81STimur Tabi 	p = strchr(p, ',');
269*a5dbdc81STimur Tabi 	*options = p ? p + 1 : NULL;
270*a5dbdc81STimur Tabi 
271*a5dbdc81STimur Tabi 	return 1;
272*a5dbdc81STimur Tabi }
273