All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Marius Vlad <marius.c.vlad@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter
Date: Wed, 04 May 2016 18:47:09 +0300	[thread overview]
Message-ID: <87lh3pn7uq.fsf@intel.com> (raw)
In-Reply-To: <20160504152558.GA20351@mcvlad-wk.rb.intel.com>

On Wed, 04 May 2016, Marius Vlad <marius.c.vlad@intel.com> wrote:
> On Tue, May 03, 2016 at 05:18:54PM +0300, Jani Nikula wrote:
>> Not sure it's a great idea to do platform specific parsing of the BIOS,
>> but at least make it possible to pass in the devid on the command line
>> and not just the environment.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  tools/intel_bios_reader.c | 35 ++++++++++++++++++++++++-----------
>>  1 file changed, 24 insertions(+), 11 deletions(-)
>> 
>> diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
>> index b424b17e4852..d74e766250df 100644
>> --- a/tools/intel_bios_reader.c
>> +++ b/tools/intel_bios_reader.c
>> @@ -41,7 +41,7 @@
>>  #include "intel_chipset.h"
>>  #include "drmtest.h"
>>  
>> -static uint32_t devid = -1;
>> +static uint32_t devid;
>>  
>>  /* no bother to include "edid.h" */
>>  #define _H_ACTIVE(x) (x[2] + ((x[4] & 0xF0) << 4))
>> @@ -149,8 +149,10 @@ static void dump_general_features(const struct bdb_header *bdb,
>>  	printf("\tExternal VBT: %s\n", YESNO(features->download_ext_vbt));
>>  	printf("\tEnable SSC: %s\n", YESNO(features->enable_ssc));
>>  	if (features->enable_ssc) {
>> -		if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid) ||
>> -		    IS_BROXTON(devid))
>> +		if (!devid)
>> +			printf("\tSSC frequency: <unknown platform>\n");
>> +		else if (IS_VALLEYVIEW(devid) || IS_CHERRYVIEW(devid) ||
>> +			 IS_BROXTON(devid))
>>  			printf("\tSSC frequency: 100 MHz\n");
>>  		else if (HAS_PCH_SPLIT(devid))
>>  			printf("\tSSC frequency: %s\n", features->ssc_freq ?
>> @@ -1375,6 +1377,7 @@ enum opt {
>>  	OPT_UNKNOWN = '?',
>>  	OPT_END = -1,
>>  	OPT_FILE,
>> +	OPT_DEVID,
>>  };
>>  
>>  int main(int argc, char **argv)
>> @@ -1392,10 +1395,11 @@ int main(int argc, char **argv)
>>  	struct bdb_block *block;
>>  	struct bdb_header *bdb;
>>  	char signature[17];
>> -	char *devid_string;
>> +	char *endp;
>>  
>>  	static struct option options[] = {
>>  		{ "file",	required_argument,	NULL,	OPT_FILE },
>> +		{ "devid",	required_argument,	NULL,	OPT_DEVID },
>>  		{ 0 }
>>  	};
>>  
>> @@ -1406,6 +1410,13 @@ int main(int argc, char **argv)
>>  		case OPT_FILE:
>>  			filename = optarg;
>>  			break;
>> +		case OPT_DEVID:
>> +			devid = strtoul(optarg, &endp, 16);
>> +			if (!devid || *endp) {
>> +				fprintf(stderr, "invalid devid '%s'\n", optarg);
>> +				return EXIT_FAILURE;
>> +			}
>> +			break;
>>  		case OPT_END:
>>  			break;
>>  		case OPT_UNKNOWN:
>> @@ -1426,9 +1437,6 @@ int main(int argc, char **argv)
>>  		}
>>  	}
>>  
>> -	if ((devid_string = getenv("DEVICE")))
>> -	    devid = strtoul(devid_string, NULL, 0);
>> -
>>  	fd = open(filename, O_RDONLY);
>>  	if (fd == -1) {
>>  		printf("Couldn't open \"%s\": %s\n", filename, strerror(errno));
>> @@ -1506,10 +1514,15 @@ int main(int argc, char **argv)
>>  	}
>>  	printf("\n");
>>  
>> -	if (devid == -1)
>> -	    devid = get_device_id(VBIOS, size);
>> -	if (devid == -1)
>> -	    printf("Warning: could not find PCI device ID!\n");
>> +	if (!devid) {
>> +		const char *devid_string = getenv("DEVICE");
>> +		if (devid_string)
>> +			devid = strtoul(devid_string, NULL, 0);
> Wouldn't this allow to pass either base 10, 16 or 8? (as an argument
> devid seems to be always specified in base 16).

That's a change in how the DEVICE environment variable was handled
previously, but indeed should be changed.

Thanks,
Jani.

>> +	}
>> +	if (!devid)
>> +		devid = get_device_id(VBIOS, size);
>> +	if (!devid)
>> +		fprintf(stderr, "Warning: could not find PCI device ID!\n");
>>  
>>  	dump_section(bdb, BDB_GENERAL_FEATURES, size);
>>  	dump_section(bdb, BDB_GENERAL_DEFINITIONS, size);
>> -- 
>> 2.1.4
>> 
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-05-04 15:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 14:18 [PATCH i-g-t 00/17] tools/intel_bios_reader updates Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 01/17] tools/intel_bios_reader: drop unused macros Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 02/17] tools/intel_bios_reader: make VBIOS non-global Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 03/17] tools/intel_bios_reader: add command line option parsing and --file parameter Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 04/17] tools/intel_bios_reader: add --devid parameter Jani Nikula
2016-05-04 15:25   ` Marius Vlad
2016-05-04 15:47     ` Jani Nikula [this message]
2016-05-03 14:18 ` [PATCH i-g-t 05/17] tools/intel_bios_reader: drop unused lvds_support variable Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 06/17] tools/intel_bios_reader: drop silly tv_present variable and printout Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 07/17] tools/intel_bios_reader: pass around a context pointer instead of bdb_header Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 08/17] tools/intel_bios_reader: move more globals to struct context Jani Nikula
2016-05-03 14:18 ` [PATCH i-g-t 09/17] tools/intel_bios_reader: move devid to context too Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 10/17] tools/intel_bios_reader: drop dependencies on lvds block parsing Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 11/17] tools/intel_bios_reader: let the user specify panel type on the command line Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 12/17] tools/intel_bios_reader: dump the blocks in numerical order Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 13/17] tools/intel_bios_reader: add --hexdump option to dump hex, disable by default Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 14/17] tools/intel_bios_reader: add support for dumping only specific section Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 15/17] tools/intel_bios_reader: add --all-panels option to dump all panels Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 16/17] tools/intel_bios_reader: free the block returned by find_section Jani Nikula
2016-05-03 14:19 ` [PATCH i-g-t 17/17] man: update intel_bios_reader man page Jani Nikula
2016-05-04 17:35 ` [PATCH i-g-t 00/17] tools/intel_bios_reader updates Marius Vlad
2016-05-12 11:18   ` Jani Nikula

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=87lh3pn7uq.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=marius.c.vlad@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.