xref: /rk3399_rockchip-uboot/drivers/video/videomodes.c (revision 92a88c33f0b063f0a6a6beff9d67506b5adcc242)
1352d2591SJean-Christophe PLAGNIOL-VILLARD /*
2352d2591SJean-Christophe PLAGNIOL-VILLARD  * (C) Copyright 2004
3352d2591SJean-Christophe PLAGNIOL-VILLARD  * Pierre Aubert, Staubli Faverges , <p.aubert@staubli.com>
4a5dbdc81STimur Tabi  * Copyright 2011 Freescale Semiconductor, Inc.
5352d2591SJean-Christophe PLAGNIOL-VILLARD  *
61a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
7352d2591SJean-Christophe PLAGNIOL-VILLARD  */
8352d2591SJean-Christophe PLAGNIOL-VILLARD 
9352d2591SJean-Christophe PLAGNIOL-VILLARD /************************************************************************
10352d2591SJean-Christophe PLAGNIOL-VILLARD   Get Parameters for the video mode:
116d0f6bcfSJean-Christophe PLAGNIOL-VILLARD   The default video mode can be defined in CONFIG_SYS_DEFAULT_VIDEO_MODE.
12352d2591SJean-Christophe PLAGNIOL-VILLARD   If undefined, default video mode is set to 0x301
13352d2591SJean-Christophe PLAGNIOL-VILLARD   Parameters can be set via the variable "videomode" in the environment.
14352d2591SJean-Christophe PLAGNIOL-VILLARD   2 diferent ways are possible:
15352d2591SJean-Christophe PLAGNIOL-VILLARD   "videomode=301"   - 301 is a hexadecimal number describing the VESA
16352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode. Following modes are implemented:
17352d2591SJean-Christophe PLAGNIOL-VILLARD 
18352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Colors	640x480 800x600 1024x768 1152x864 1280x1024
19352d2591SJean-Christophe PLAGNIOL-VILLARD 		     --------+---------------------------------------------
20352d2591SJean-Christophe PLAGNIOL-VILLARD 		      8 bits |	0x301	0x303	 0x305	  0x161	    0x307
21352d2591SJean-Christophe PLAGNIOL-VILLARD 		     15 bits |	0x310	0x313	 0x316	  0x162	    0x319
22352d2591SJean-Christophe PLAGNIOL-VILLARD 		     16 bits |	0x311	0x314	 0x317	  0x163	    0x31A
23352d2591SJean-Christophe PLAGNIOL-VILLARD 		     24 bits |	0x312	0x315	 0x318	    ?	    0x31B
24352d2591SJean-Christophe PLAGNIOL-VILLARD 		     --------+---------------------------------------------
25352d2591SJean-Christophe PLAGNIOL-VILLARD   "videomode=bootargs"
26352d2591SJean-Christophe PLAGNIOL-VILLARD 		   - the parameters are parsed from the bootargs.
27352d2591SJean-Christophe PLAGNIOL-VILLARD 		      The format is "NAME:VALUE,NAME:VALUE" etc.
28352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Ex.:
29352d2591SJean-Christophe PLAGNIOL-VILLARD 		      "bootargs=video=ctfb:x:800,y:600,depth:16,pclk:25000"
30352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Parameters not included in the list will be taken from
31352d2591SJean-Christophe PLAGNIOL-VILLARD 		      the default mode, which is one of the following:
32352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:0  640x480x24
33352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:1  800x600x16
34352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:2  1024x768x8
35352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:3  960x720x24
36352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:4  1152x864x16
37352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:5  1280x1024x8
38352d2591SJean-Christophe PLAGNIOL-VILLARD 
39352d2591SJean-Christophe PLAGNIOL-VILLARD 		      if "mode" is not provided within the parameter list,
40352d2591SJean-Christophe PLAGNIOL-VILLARD 		      mode:0 is assumed.
41352d2591SJean-Christophe PLAGNIOL-VILLARD 		      Following parameters are supported:
42352d2591SJean-Christophe PLAGNIOL-VILLARD 		      x	      xres = visible resolution horizontal
43352d2591SJean-Christophe PLAGNIOL-VILLARD 		      y	      yres = visible resolution vertical
44352d2591SJean-Christophe PLAGNIOL-VILLARD 		      pclk    pixelclocks in pico sec
45352d2591SJean-Christophe PLAGNIOL-VILLARD 		      le      left_marging time from sync to picture in pixelclocks
46352d2591SJean-Christophe PLAGNIOL-VILLARD 		      ri      right_marging time from picture to sync in pixelclocks
47352d2591SJean-Christophe PLAGNIOL-VILLARD 		      up      upper_margin time from sync to picture
48352d2591SJean-Christophe PLAGNIOL-VILLARD 		      lo      lower_margin
49352d2591SJean-Christophe PLAGNIOL-VILLARD 		      hs      hsync_len length of horizontal sync
50352d2591SJean-Christophe PLAGNIOL-VILLARD 		      vs      vsync_len length of vertical sync
51352d2591SJean-Christophe PLAGNIOL-VILLARD 		      sync    see FB_SYNC_*
52352d2591SJean-Christophe PLAGNIOL-VILLARD 		      vmode   see FB_VMODE_*
53352d2591SJean-Christophe PLAGNIOL-VILLARD 		      depth   Color depth in bits per pixel
54352d2591SJean-Christophe PLAGNIOL-VILLARD 		      All other parameters in the variable bootargs are ignored.
55352d2591SJean-Christophe PLAGNIOL-VILLARD 		      It is also possible to set the parameters direct in the
56352d2591SJean-Christophe PLAGNIOL-VILLARD 		      variable "videomode", or in another variable i.e.
57352d2591SJean-Christophe PLAGNIOL-VILLARD 		      "myvideo" and setting the variable "videomode=myvideo"..
58352d2591SJean-Christophe PLAGNIOL-VILLARD ****************************************************************************/
59352d2591SJean-Christophe PLAGNIOL-VILLARD 
60352d2591SJean-Christophe PLAGNIOL-VILLARD #include <common.h>
61a5dbdc81STimur Tabi #include <linux/ctype.h>
62a5dbdc81STimur Tabi 
63352d2591SJean-Christophe PLAGNIOL-VILLARD #include "videomodes.h"
64352d2591SJean-Christophe PLAGNIOL-VILLARD 
65352d2591SJean-Christophe PLAGNIOL-VILLARD const struct ctfb_vesa_modes vesa_modes[VESA_MODES_COUNT] = {
66352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x301, RES_MODE_640x480, 8},
67352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x310, RES_MODE_640x480, 15},
68352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x311, RES_MODE_640x480, 16},
69352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x312, RES_MODE_640x480, 24},
70352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x303, RES_MODE_800x600, 8},
71352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x313, RES_MODE_800x600, 15},
72352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x314, RES_MODE_800x600, 16},
73352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x315, RES_MODE_800x600, 24},
74352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x305, RES_MODE_1024x768, 8},
75352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x316, RES_MODE_1024x768, 15},
76352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x317, RES_MODE_1024x768, 16},
77352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x318, RES_MODE_1024x768, 24},
78352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x161, RES_MODE_1152x864, 8},
79352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x162, RES_MODE_1152x864, 15},
80352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x163, RES_MODE_1152x864, 16},
81352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x307, RES_MODE_1280x1024, 8},
82352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x319, RES_MODE_1280x1024, 15},
83352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x31A, RES_MODE_1280x1024, 16},
84352d2591SJean-Christophe PLAGNIOL-VILLARD 	{0x31B, RES_MODE_1280x1024, 24},
85352d2591SJean-Christophe PLAGNIOL-VILLARD };
86352d2591SJean-Christophe PLAGNIOL-VILLARD const struct ctfb_res_modes res_mode_init[RES_MODES_COUNT] = {
870c91d257SHans de Goede 	/*  x     y  hz  pixclk ps/kHz   le   ri  up  lo   hs vs  s  vmode */
88*92a88c33SHans de Goede #ifndef CONFIG_VIDEO_STD_TIMINGS
890c91d257SHans de Goede 	{ 640,  480, 60, 39721,  25180,  40,  24, 32, 11,  96, 2, 0, FB_VMODE_NONINTERLACED},
900c91d257SHans de Goede 	{ 800,  600, 60, 27778,  36000,  64,  24, 22,  1,  72, 2, 0, FB_VMODE_NONINTERLACED},
910c91d257SHans de Goede 	{1024,  768, 60, 15384,  65000, 168,   8, 29,  3, 144, 4, 0, FB_VMODE_NONINTERLACED},
920c91d257SHans de Goede 	{ 960,  720, 80, 13100,  76335, 160,  40, 32,  8,  80, 4, 0, FB_VMODE_NONINTERLACED},
930c91d257SHans de Goede 	{1152,  864, 60, 12004,  83300, 200,  64, 32, 16,  80, 4, 0, FB_VMODE_NONINTERLACED},
940c91d257SHans de Goede 	{1280, 1024, 60,  9090, 110000, 200,  48, 26,  1, 184, 3, 0, FB_VMODE_NONINTERLACED},
95*92a88c33SHans de Goede #else
96*92a88c33SHans de Goede 	{ 640,  480, 60, 39683,  25200,  48,  16, 33, 10,  96, 2, 0, FB_VMODE_NONINTERLACED},
97*92a88c33SHans de Goede 	{ 800,  600, 60, 25000,  40000,  88,  40, 23,  1, 128, 4, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
98*92a88c33SHans de Goede 	{1024,  768, 60, 15384,  65000, 160,  24, 29,  3, 136, 6, 0, FB_VMODE_NONINTERLACED},
99*92a88c33SHans de Goede 	{ 960,  720, 75, 13468,  74250, 176,  72, 27,  1, 112, 2, 0, FB_VMODE_NONINTERLACED},
100*92a88c33SHans de Goede 	{1152,  864, 75,  9259, 108000, 256,  64, 32,  1, 128, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
101*92a88c33SHans de Goede 	{1280, 1024, 60,  9259, 108000, 248,  48, 38,  1, 112, 3, FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
102*92a88c33SHans de Goede #endif
103352d2591SJean-Christophe PLAGNIOL-VILLARD };
104352d2591SJean-Christophe PLAGNIOL-VILLARD 
105352d2591SJean-Christophe PLAGNIOL-VILLARD /************************************************************************
106352d2591SJean-Christophe PLAGNIOL-VILLARD  * Get Parameters for the video mode:
107352d2591SJean-Christophe PLAGNIOL-VILLARD  */
108352d2591SJean-Christophe PLAGNIOL-VILLARD /*********************************************************************
109352d2591SJean-Christophe PLAGNIOL-VILLARD  * returns the length to the next seperator
110352d2591SJean-Christophe PLAGNIOL-VILLARD  */
111352d2591SJean-Christophe PLAGNIOL-VILLARD static int
112352d2591SJean-Christophe PLAGNIOL-VILLARD video_get_param_len (char *start, char sep)
113352d2591SJean-Christophe PLAGNIOL-VILLARD {
114352d2591SJean-Christophe PLAGNIOL-VILLARD 	int i = 0;
115352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((*start != 0) && (*start != sep)) {
116352d2591SJean-Christophe PLAGNIOL-VILLARD 		start++;
117352d2591SJean-Christophe PLAGNIOL-VILLARD 		i++;
118352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
119352d2591SJean-Christophe PLAGNIOL-VILLARD 	return i;
120352d2591SJean-Christophe PLAGNIOL-VILLARD }
121352d2591SJean-Christophe PLAGNIOL-VILLARD 
122352d2591SJean-Christophe PLAGNIOL-VILLARD static int
123352d2591SJean-Christophe PLAGNIOL-VILLARD video_search_param (char *start, char *param)
124352d2591SJean-Christophe PLAGNIOL-VILLARD {
125352d2591SJean-Christophe PLAGNIOL-VILLARD 	int len, totallen, i;
126352d2591SJean-Christophe PLAGNIOL-VILLARD 	char *p = start;
127352d2591SJean-Christophe PLAGNIOL-VILLARD 	len = strlen (param);
128352d2591SJean-Christophe PLAGNIOL-VILLARD 	totallen = len + strlen (start);
129352d2591SJean-Christophe PLAGNIOL-VILLARD 	for (i = 0; i < totallen; i++) {
130352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (strncmp (p++, param, len) == 0)
131352d2591SJean-Christophe PLAGNIOL-VILLARD 			return (i);
132352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
133352d2591SJean-Christophe PLAGNIOL-VILLARD 	return -1;
134352d2591SJean-Christophe PLAGNIOL-VILLARD }
135352d2591SJean-Christophe PLAGNIOL-VILLARD 
136352d2591SJean-Christophe PLAGNIOL-VILLARD /***************************************************************
137352d2591SJean-Christophe PLAGNIOL-VILLARD  * Get parameter via the environment as it is done for the
138352d2591SJean-Christophe PLAGNIOL-VILLARD  * linux kernel i.e:
139352d2591SJean-Christophe PLAGNIOL-VILLARD  * video=ctfb:x:800,xv:1280,y:600,yv:1024,depth:16,mode:0,pclk:25000,
140352d2591SJean-Christophe PLAGNIOL-VILLARD  *	 le:56,ri:48,up:26,lo:5,hs:152,vs:2,sync:0,vmode:0,accel:0
141352d2591SJean-Christophe PLAGNIOL-VILLARD  *
142352d2591SJean-Christophe PLAGNIOL-VILLARD  * penv is a pointer to the environment, containing the string, or the name of
143352d2591SJean-Christophe PLAGNIOL-VILLARD  * another environment variable. It could even be the term "bootargs"
144352d2591SJean-Christophe PLAGNIOL-VILLARD  */
145352d2591SJean-Christophe PLAGNIOL-VILLARD 
146352d2591SJean-Christophe PLAGNIOL-VILLARD #define GET_OPTION(name,var)				\
147352d2591SJean-Christophe PLAGNIOL-VILLARD 	if(strncmp(p,name,strlen(name))==0) {		\
148352d2591SJean-Christophe PLAGNIOL-VILLARD 		val_s=p+strlen(name);			\
149352d2591SJean-Christophe PLAGNIOL-VILLARD 		var=simple_strtoul(val_s, NULL, 10);	\
150352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
151352d2591SJean-Christophe PLAGNIOL-VILLARD 
152352d2591SJean-Christophe PLAGNIOL-VILLARD int video_get_params (struct ctfb_res_modes *pPar, char *penv)
153352d2591SJean-Christophe PLAGNIOL-VILLARD {
154352d2591SJean-Christophe PLAGNIOL-VILLARD 	char *p, *s, *val_s;
15540ac78a9SWolfgang Denk 	int i = 0;
156352d2591SJean-Christophe PLAGNIOL-VILLARD 	int bpp;
157352d2591SJean-Christophe PLAGNIOL-VILLARD 	int mode;
15840ac78a9SWolfgang Denk 
159352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* first search for the environment containing the real param string */
160352d2591SJean-Christophe PLAGNIOL-VILLARD 	s = penv;
16140ac78a9SWolfgang Denk 
16240ac78a9SWolfgang Denk 	if ((p = getenv (s)) != NULL)
163352d2591SJean-Christophe PLAGNIOL-VILLARD 		s = p;
16440ac78a9SWolfgang Denk 
16540ac78a9SWolfgang Denk 	/*
16640ac78a9SWolfgang Denk 	 * in case of the bootargs line, we have to start
167352d2591SJean-Christophe PLAGNIOL-VILLARD 	 * after "video=ctfb:"
168352d2591SJean-Christophe PLAGNIOL-VILLARD 	 */
169352d2591SJean-Christophe PLAGNIOL-VILLARD 	i = video_search_param (s, "video=ctfb:");
170352d2591SJean-Christophe PLAGNIOL-VILLARD 	if (i >= 0) {
171352d2591SJean-Christophe PLAGNIOL-VILLARD 		s += i;
172352d2591SJean-Christophe PLAGNIOL-VILLARD 		s += strlen ("video=ctfb:");
173352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
174352d2591SJean-Christophe PLAGNIOL-VILLARD 	/* search for mode as a default value */
175352d2591SJean-Christophe PLAGNIOL-VILLARD 	p = s;
176352d2591SJean-Christophe PLAGNIOL-VILLARD 	mode = 0;		/* default */
17740ac78a9SWolfgang Denk 
178352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((i = video_get_param_len (p, ',')) != 0) {
179352d2591SJean-Christophe PLAGNIOL-VILLARD 		GET_OPTION ("mode:", mode)
180352d2591SJean-Christophe PLAGNIOL-VILLARD 			p += i;
181352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (*p != 0)
182352d2591SJean-Christophe PLAGNIOL-VILLARD 			p++;	/* skip ',' */
183352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
18440ac78a9SWolfgang Denk 
185352d2591SJean-Christophe PLAGNIOL-VILLARD 	if (mode >= RES_MODES_COUNT)
186352d2591SJean-Christophe PLAGNIOL-VILLARD 		mode = 0;
18740ac78a9SWolfgang Denk 
188352d2591SJean-Christophe PLAGNIOL-VILLARD 	*pPar = res_mode_init[mode];	/* copy default values */
189352d2591SJean-Christophe PLAGNIOL-VILLARD 	bpp = 24 - ((mode % 3) * 8);
190352d2591SJean-Christophe PLAGNIOL-VILLARD 	p = s;			/* restart */
19140ac78a9SWolfgang Denk 
192352d2591SJean-Christophe PLAGNIOL-VILLARD 	while ((i = video_get_param_len (p, ',')) != 0) {
193352d2591SJean-Christophe PLAGNIOL-VILLARD 		GET_OPTION ("x:", pPar->xres)
194352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("y:", pPar->yres)
1950c91d257SHans de Goede 			GET_OPTION ("refresh:", pPar->refresh)
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)
2050c91d257SHans de Goede 			GET_OPTION ("pclk_khz:", pPar->pixclock_khz)
206352d2591SJean-Christophe PLAGNIOL-VILLARD 			GET_OPTION ("depth:", bpp)
207352d2591SJean-Christophe PLAGNIOL-VILLARD 			p += i;
208352d2591SJean-Christophe PLAGNIOL-VILLARD 		if (*p != 0)
209352d2591SJean-Christophe PLAGNIOL-VILLARD 			p++;	/* skip ',' */
210352d2591SJean-Christophe PLAGNIOL-VILLARD 	}
211352d2591SJean-Christophe PLAGNIOL-VILLARD 	return bpp;
212352d2591SJean-Christophe PLAGNIOL-VILLARD }
213a5dbdc81STimur Tabi 
214a5dbdc81STimur Tabi /*
215a5dbdc81STimur Tabi  * Parse the 'video-mode' environment variable
216a5dbdc81STimur Tabi  *
217a5dbdc81STimur Tabi  * Example: "video-mode=fslfb:1280x1024-32@60,monitor=dvi".  See
218a5dbdc81STimur Tabi  * doc/README.video for more information on how to set the variable.
219a5dbdc81STimur Tabi  *
220a5dbdc81STimur Tabi  * @xres: returned value of X-resolution
221a5dbdc81STimur Tabi  * @yres: returned value of Y-resolution
222a5dbdc81STimur Tabi  * @depth: returned value of color depth
223a5dbdc81STimur Tabi  * @freq: returned value of monitor frequency
224a5dbdc81STimur Tabi  * @options: pointer to any remaining options, or NULL
225a5dbdc81STimur Tabi  *
226a5dbdc81STimur Tabi  * Returns 1 if valid values were found, 0 otherwise
227a5dbdc81STimur Tabi  */
228a5dbdc81STimur Tabi int video_get_video_mode(unsigned int *xres, unsigned int *yres,
229a5dbdc81STimur Tabi 	unsigned int *depth, unsigned int *freq, const char **options)
230a5dbdc81STimur Tabi {
231a5dbdc81STimur Tabi 	char *p = getenv("video-mode");
232a5dbdc81STimur Tabi 	if (!p)
233a5dbdc81STimur Tabi 		return 0;
234a5dbdc81STimur Tabi 
235a5dbdc81STimur Tabi 	/* Skip over the driver name, which we don't care about. */
236a5dbdc81STimur Tabi 	p = strchr(p, ':');
237a5dbdc81STimur Tabi 	if (!p)
238a5dbdc81STimur Tabi 		return 0;
239a5dbdc81STimur Tabi 
240a5dbdc81STimur Tabi 	/* Get the X-resolution*/
241a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
242a5dbdc81STimur Tabi 		p++;
243a5dbdc81STimur Tabi 	*xres = simple_strtoul(p, &p, 10);
244a5dbdc81STimur Tabi 	if (!*xres)
245a5dbdc81STimur Tabi 		return 0;
246a5dbdc81STimur Tabi 
247a5dbdc81STimur Tabi 	/* Get the Y-resolution */
248a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
249a5dbdc81STimur Tabi 		p++;
250a5dbdc81STimur Tabi 	*yres = simple_strtoul(p, &p, 10);
251a5dbdc81STimur Tabi 	if (!*yres)
252a5dbdc81STimur Tabi 		return 0;
253a5dbdc81STimur Tabi 
254a5dbdc81STimur Tabi 	/* Get the depth */
255a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
256a5dbdc81STimur Tabi 		p++;
257a5dbdc81STimur Tabi 	*depth = simple_strtoul(p, &p, 10);
258a5dbdc81STimur Tabi 	if (!*depth)
259a5dbdc81STimur Tabi 		return 0;
260a5dbdc81STimur Tabi 
261a5dbdc81STimur Tabi 	/* Get the frequency */
262a5dbdc81STimur Tabi 	while (*p && !isdigit(*p))
263a5dbdc81STimur Tabi 		p++;
264a5dbdc81STimur Tabi 	*freq = simple_strtoul(p, &p, 10);
265a5dbdc81STimur Tabi 	if (!*freq)
266a5dbdc81STimur Tabi 		return 0;
267a5dbdc81STimur Tabi 
268a5dbdc81STimur Tabi 	/* Find the extra options, if any */
269a5dbdc81STimur Tabi 	p = strchr(p, ',');
270a5dbdc81STimur Tabi 	*options = p ? p + 1 : NULL;
271a5dbdc81STimur Tabi 
272a5dbdc81STimur Tabi 	return 1;
273a5dbdc81STimur Tabi }
274