public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 05/11] videomodes: Add helper functions to parse video-mode env-var extra options
Date: Mon, 22 Dec 2014 16:58:46 +0100	[thread overview]
Message-ID: <54983FB6.8000106@redhat.com> (raw)
In-Reply-To: <1419251715.26985.167.camel@hellion.org.uk>

Hi,

On 22-12-14 13:35, Ian Campbell wrote:
> On Fri, 2014-12-19 at 18:10 +0100, Hans de Goede wrote:
>> Add 2 helper functions to get strings, reps. ints from the options value
>> returned by video_get_video_mode() / video_get_ctfb_res_modes().
>
> I can't quite parse this, what is "reps. ints"?

Oops sorry, that should be resp. for respectively, so with the abbreviations
dropped it should read:

"Add 2 helper functions to get strings, respectively integers from the options
value returned by video_get_video_mode() / video_get_ctfb_res_modes()."

Which hopefully is more clear, I've fixed this in my personal tree.

> Also, it's "separated" not "seperated" (throughout).

I've also fixed this in my personal tree.

Thanks & Regards,

Hans


>
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/video/videomodes.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-
>>   drivers/video/videomodes.h |  5 ++++
>>   2 files changed, 64 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
>> index 72841fd..1f79d5f 100644
>> --- a/drivers/video/videomodes.c
>> +++ b/drivers/video/videomodes.c
>> @@ -113,7 +113,7 @@ const struct ctfb_res_modes res_mode_init[RES_MODES_COUNT] = {
>>    * returns the length to the next seperator
>>    */
>>   static int
>> -video_get_param_len (char *start, char sep)
>> +video_get_param_len (const char *start, char sep)
>>   {
>>   	int i = 0;
>>   	while ((*start != 0) && (*start != sep)) {
>> @@ -313,3 +313,61 @@ void video_get_ctfb_res_modes(int default_mode, unsigned int default_depth,
>>   	       xres, yres, depth, refresh, (*mode_ret)->xres,
>>   	       (*mode_ret)->yres, *depth_ret, (*mode_ret)->refresh);
>>   }
>> +
>> +/*
>> + * Find the named string option within the ',' seperated options string, and
>> + * store its value in dest.
>> + *
>> + * @options: ',' seperated options string
>> + * @name: name of the option to look for
>> + * @dest: destination buffer to store the value of the option in
>> + * @dest_len: length of dest
>> + * @def: value to store in dest if the option is not present in options
>> + */
>> +void video_get_option_string(const char *options, const char *name,
>> +			     char *dest, int dest_len, const char *def)
>> +{
>> +	const char *p = options;
>> +	const int name_len = strlen(name);
>> +	int i, len;
>> +
>> +	while (p && (i = video_get_param_len (p, ',')) != 0) {
>> +		if (strncmp(p, name, name_len) == 0 && p[name_len] == '=') {
>> +			len = i - (name_len + 1);
>> +			if (len >= dest_len)
>> +				len = dest_len - 1;
>> +			memcpy(dest, &p[name_len + 1], len);
>> +			dest[len] = 0;
>> +			return;
>> +		}
>> +		p += i;
>> +		if (*p != 0)
>> +			p++;	/* skip ',' */
>> +	}
>> +	strcpy(dest, def);
>> +}
>> +
>> +/*
>> + * Find the named integer option within the ',' seperated options string, and
>> + * return its value.
>> + *
>> + * @options: ',' seperated options string
>> + * @name: name of the option to look for
>> + * @def: value to return if the option is not present in options
>> + */
>> +int video_get_option_int(const char *options, const char *name, int def)
>> +{
>> +	const char *p = options;
>> +	const int name_len = strlen(name);
>> +	int i;
>> +
>> +	while (p && (i = video_get_param_len (p, ',')) != 0) {
>> +		if (strncmp(p, name, name_len) == 0 && p[name_len] == '=')
>> +			return simple_strtoul(&p[name_len + 1], NULL, 10);
>> +
>> +		p += i;
>> +		if (*p != 0)
>> +			p++;	/* skip ',' */
>> +	}
>> +	return def;
>> +}
>> diff --git a/drivers/video/videomodes.h b/drivers/video/videomodes.h
>> index 02419cd..047b8a9 100644
>> --- a/drivers/video/videomodes.h
>> +++ b/drivers/video/videomodes.h
>> @@ -84,3 +84,8 @@ void video_get_ctfb_res_modes(int default_mode, unsigned int default_depth,
>>   			      const struct ctfb_res_modes **mode_ret,
>>   			      unsigned int *depth_ret,
>>   			      const char **options);
>> +
>> +void video_get_option_string(const char *options, const char *name,
>> +			     char *dest, int dest_len, const char *def);
>> +
>> +int video_get_option_int(const char *options, const char *name, int def);
>
>

  reply	other threads:[~2014-12-22 15:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19 17:10 [U-Boot] [PATCH v2 00/11] video: Add / fix videomodes modes, use for sunxi, enable EDID on sunxi Hans de Goede
2014-12-19 17:10 ` [U-Boot] [PATCH v2 01/11] videomodes: Add pixelclock_khz and refresh fields to ctfb_res_modes Hans de Goede
2015-01-08 14:26   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 02/11] videomodes: Add (vesa) standard timings Hans de Goede
2015-01-08 14:29   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 03/11] videomodes: Add a bunch of high res modes Hans de Goede
2015-01-08 14:30   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 04/11] videomodes: Add video_get_ctfb_res_modes helper function Hans de Goede
2015-01-08 14:56   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 05/11] videomodes: Add helper functions to parse video-mode env-var extra options Hans de Goede
2014-12-22 12:35   ` Ian Campbell
2014-12-22 15:58     ` Hans de Goede [this message]
2015-01-08 15:40   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 06/11] videomodes: Add video_edid_dtd_to_ctfb_res_modes helper function Hans de Goede
2015-01-08 15:52   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 07/11] edid: Add an edid_check_checksum() " Hans de Goede
2015-01-08 15:55   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 08/11] sunxi: video: Use video-mode/-timing from videomodes Hans de Goede
2014-12-22 12:36   ` Ian Campbell
2015-01-08 16:06   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 09/11] sunxi: video: Add support for video-mode environment variable Hans de Goede
2014-12-22 12:37   ` Ian Campbell
2015-01-08 16:08   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 10/11] sunxi: video: Add hpd option Hans de Goede
2014-12-22 12:39   ` Ian Campbell
2015-01-08 16:12   ` Anatolij Gustschin
2014-12-19 17:10 ` [U-Boot] [PATCH v2 11/11] sunxi: video: Add DDC & EDID support Hans de Goede
2014-12-22 12:41   ` Ian Campbell
2015-01-08 16:25   ` Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54983FB6.8000106@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox