head 1.2; access; symbols pkgsrc-2026Q1:1.2.0.118 pkgsrc-2026Q1-base:1.2 pkgsrc-2025Q4:1.2.0.116 pkgsrc-2025Q4-base:1.2 pkgsrc-2025Q3:1.2.0.114 pkgsrc-2025Q3-base:1.2 pkgsrc-2025Q2:1.2.0.112 pkgsrc-2025Q2-base:1.2 pkgsrc-2025Q1:1.2.0.110 pkgsrc-2025Q1-base:1.2 pkgsrc-2024Q4:1.2.0.108 pkgsrc-2024Q4-base:1.2 pkgsrc-2024Q3:1.2.0.106 pkgsrc-2024Q3-base:1.2 pkgsrc-2024Q2:1.2.0.104 pkgsrc-2024Q2-base:1.2 pkgsrc-2024Q1:1.2.0.102 pkgsrc-2024Q1-base:1.2 pkgsrc-2023Q4:1.2.0.100 pkgsrc-2023Q4-base:1.2 pkgsrc-2023Q3:1.2.0.98 pkgsrc-2023Q3-base:1.2 pkgsrc-2023Q2:1.2.0.96 pkgsrc-2023Q2-base:1.2 pkgsrc-2023Q1:1.2.0.94 pkgsrc-2023Q1-base:1.2 pkgsrc-2022Q4:1.2.0.92 pkgsrc-2022Q4-base:1.2 pkgsrc-2022Q3:1.2.0.90 pkgsrc-2022Q3-base:1.2 pkgsrc-2022Q2:1.2.0.88 pkgsrc-2022Q2-base:1.2 pkgsrc-2022Q1:1.2.0.86 pkgsrc-2022Q1-base:1.2 pkgsrc-2021Q4:1.2.0.84 pkgsrc-2021Q4-base:1.2 pkgsrc-2021Q3:1.2.0.82 pkgsrc-2021Q3-base:1.2 pkgsrc-2021Q2:1.2.0.80 pkgsrc-2021Q2-base:1.2 pkgsrc-2021Q1:1.2.0.78 pkgsrc-2021Q1-base:1.2 pkgsrc-2020Q4:1.2.0.76 pkgsrc-2020Q4-base:1.2 pkgsrc-2020Q3:1.2.0.74 pkgsrc-2020Q3-base:1.2 pkgsrc-2020Q2:1.2.0.70 pkgsrc-2020Q2-base:1.2 pkgsrc-2020Q1:1.2.0.50 pkgsrc-2020Q1-base:1.2 pkgsrc-2019Q4:1.2.0.72 pkgsrc-2019Q4-base:1.2 pkgsrc-2019Q3:1.2.0.68 pkgsrc-2019Q3-base:1.2 pkgsrc-2019Q2:1.2.0.66 pkgsrc-2019Q2-base:1.2 pkgsrc-2019Q1:1.2.0.64 pkgsrc-2019Q1-base:1.2 pkgsrc-2018Q4:1.2.0.62 pkgsrc-2018Q4-base:1.2 pkgsrc-2018Q3:1.2.0.60 pkgsrc-2018Q3-base:1.2 pkgsrc-2018Q2:1.2.0.58 pkgsrc-2018Q2-base:1.2 pkgsrc-2018Q1:1.2.0.56 pkgsrc-2018Q1-base:1.2 pkgsrc-2017Q4:1.2.0.54 pkgsrc-2017Q4-base:1.2 pkgsrc-2017Q3:1.2.0.52 pkgsrc-2017Q3-base:1.2 pkgsrc-2017Q2:1.2.0.48 pkgsrc-2017Q2-base:1.2 pkgsrc-2017Q1:1.2.0.46 pkgsrc-2017Q1-base:1.2 pkgsrc-2016Q4:1.2.0.44 pkgsrc-2016Q4-base:1.2 pkgsrc-2016Q3:1.2.0.42 pkgsrc-2016Q3-base:1.2 pkgsrc-2016Q2:1.2.0.40 pkgsrc-2016Q2-base:1.2 pkgsrc-2016Q1:1.2.0.38 pkgsrc-2016Q1-base:1.2 pkgsrc-2015Q4:1.2.0.36 pkgsrc-2015Q4-base:1.2 pkgsrc-2015Q3:1.2.0.34 pkgsrc-2015Q3-base:1.2 pkgsrc-2015Q2:1.2.0.32 pkgsrc-2015Q2-base:1.2 pkgsrc-2015Q1:1.2.0.30 pkgsrc-2015Q1-base:1.2 pkgsrc-2014Q4:1.2.0.28 pkgsrc-2014Q4-base:1.2 pkgsrc-2014Q3:1.2.0.26 pkgsrc-2014Q3-base:1.2 pkgsrc-2014Q2:1.2.0.24 pkgsrc-2014Q2-base:1.2 pkgsrc-2014Q1:1.2.0.22 pkgsrc-2014Q1-base:1.2 pkgsrc-2013Q4:1.2.0.20 pkgsrc-2013Q4-base:1.2 pkgsrc-2013Q3:1.2.0.18 pkgsrc-2013Q3-base:1.2 pkgsrc-2013Q2:1.2.0.16 pkgsrc-2013Q2-base:1.2 pkgsrc-2013Q1:1.2.0.14 pkgsrc-2013Q1-base:1.2 pkgsrc-2012Q4:1.2.0.12 pkgsrc-2012Q4-base:1.2 pkgsrc-2012Q3:1.2.0.10 pkgsrc-2012Q3-base:1.2 pkgsrc-2012Q2:1.2.0.8 pkgsrc-2012Q2-base:1.2 pkgsrc-2012Q1:1.2.0.6 pkgsrc-2012Q1-base:1.2 pkgsrc-2011Q4:1.2.0.4 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q3:1.2.0.2 pkgsrc-2011Q3-base:1.2 pkgsrc-2011Q2:1.1.0.42 pkgsrc-2011Q2-base:1.1 pkgsrc-2011Q1:1.1.0.40 pkgsrc-2011Q1-base:1.1 pkgsrc-2010Q4:1.1.0.38 pkgsrc-2010Q4-base:1.1 pkgsrc-2010Q3:1.1.0.36 pkgsrc-2010Q3-base:1.1 pkgsrc-2010Q2:1.1.0.34 pkgsrc-2010Q2-base:1.1 pkgsrc-2010Q1:1.1.0.32 pkgsrc-2010Q1-base:1.1 pkgsrc-2009Q4:1.1.0.30 pkgsrc-2009Q4-base:1.1 pkgsrc-2009Q3:1.1.0.28 pkgsrc-2009Q3-base:1.1 pkgsrc-2009Q2:1.1.0.26 pkgsrc-2009Q2-base:1.1 pkgsrc-2009Q1:1.1.0.24 pkgsrc-2009Q1-base:1.1 pkgsrc-2008Q4:1.1.0.22 pkgsrc-2008Q4-base:1.1 pkgsrc-2008Q3:1.1.0.20 pkgsrc-2008Q3-base:1.1 cube-native-xorg:1.1.0.18 cube-native-xorg-base:1.1 pkgsrc-2008Q2:1.1.0.16 pkgsrc-2008Q2-base:1.1 cwrapper:1.1.0.14 pkgsrc-2008Q1:1.1.0.12 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.10 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.8 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.6 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.4 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.2 pkgsrc-2006Q4-base:1.1; locks; strict; comment @# @; 1.2 date 2011.10.01.22.32.11; author dholland; state Exp; branches; next 1.1; 1.1 date 2006.12.04.04.42.03; author christos; state Exp; branches; next ; desc @@ 1.2 log @- fix amd64 build (use size_t, not int, with getline) - provide getline only for older netbsd - don't install executable man pages @ text @$NetBSD: patch-ac,v 1.1 2006/12/04 04:42:03 christos Exp $ --- i810switch.c.orig 2005-06-12 04:36:36.000000000 +0000 +++ i810switch.c @@@@ -1,3 +1,4 @@@@ +#include #include #include #include @@@@ -9,7 +10,11 @@@@ #include #define VERSION "0.6.5beta" +#ifdef __NetBSD__ +#define CMD_LSPCI "pcictl /dev/pci0" +#else #define CMD_LSPCI "lspci" +#endif static const char *Opt_lcd = NULL; static const char *Opt_crt = NULL; @@@@ -49,19 +54,31 @@@@ struct i810_par { /* PCI IDs */ -#define I810STR "8086:7121" -#define I810ESTR "8086:7123" -#define I810_DC100STR_1 "8086:7125" -#define I810_DC100STR_2 "8086:1102" -#define I810_IGSTR "8086:1112" -#define I810_CFCSTR "8086:1132" -#define I830STR "8086:3577" -#define I845STR "8086:2562" -#define I855STR "8086:3582" -//#define I865STR "8086:2572" -#define I915STR "8086:2592" -#define MEMSTR "Memory at" +static const struct { + char *id; + int type; +} i8xx[] = { +/* I810STR */ { "7121", I810 }, +/* I810ESTR */ { "7123", I810 }, +/* I810_DC100STR_1 */ { "7125", I810 }, +/* I810_DC100STR_2 */ { "1102", I810 }, +/* I810_IGSTR */ { "1112", I810 }, +/* I810_CFCSTR */ { "1132", I810 }, +/* I830STR */ { "3577", I830 }, +/* I845STR */ { "2562", I855 }, +/* I855STR */ { "3582", I855 }, +/* I865STR { "2572", I865 }, */ +/* I915STR */ { "2592", I915 }, + { NULL, 0 }, +}; + +#ifdef __NetBSD__ +#define NONPRSTR "32-bit nonprefetchable memory" +#define MEMSTR "base:" +#else #define NONPRSTR "32-bit, non-prefetchable" +#define MEMSTR "Memory at" +#endif /* I810 registers */ #define I810_HVSYNC 0x05000 @@@@ -243,62 +260,48 @@@@ void probe_card_I830(struct i810_par *pa i810_readl(par->mmio, I830_DSPBSTRIDE)); } -char *i810_chip(char **buff_ptr, int *len_ptr, FILE *pci_f, int* chiptype) +char *i810_chip(char **buff_ptr, size_t *len_ptr, FILE *pci_f, int* chiptype) { int i; char *p; + char buf[10]; while (getline(buff_ptr, len_ptr, pci_f) > 0) { - i = (p = strstr(*buff_ptr, I810STR)) != NULL || - (p = strstr(*buff_ptr, I810ESTR)) != NULL || - (p = strstr(*buff_ptr, I810_DC100STR_1)) != NULL || - (p = strstr(*buff_ptr, I810_DC100STR_2)) != NULL || - (p = strstr(*buff_ptr, I810_IGSTR)) != NULL || - (p = strstr(*buff_ptr, I810_CFCSTR)) != NULL; - if (i) - { - *chiptype = I810; - return p; - } - - i = (p = strstr(*buff_ptr, I830STR)) != NULL || -#if defined (I865STR) - (p = strstr(*buff_ptr, I865STR)) != NULL || -#endif /*defined (I865STR)*/ - (p = strstr(*buff_ptr, I845STR)) != NULL; - if (i) - { - *chiptype = I830; - return p; - } - - i = (p = strstr(*buff_ptr, I855STR)) != NULL; - if (i) - { - *chiptype = I855; - return p; - } - - i = (p = strstr(*buff_ptr, I915STR)) != NULL; - if (i) - { - *chiptype = I915; + for (i = 0; i8xx[i].id != NULL; i++) { +#ifdef __NetBSD__ + snprintf(buf, sizeof(buf), "%s8086", i8xx[i].id); +#else + snprintf(buf, sizeof(buf), "8086:%s", i8xx[i].id); +#endif + if ((p = strstr(*buff_ptr, buf)) != NULL) + break; + } + if (i8xx[i].id) { + *chiptype = i8xx[i].type; +#ifdef __NetBSD__ + return *buff_ptr; +#else return p; +#endif } } return NULL; } -unsigned long i810_addr(char **buff_ptr, int *len_ptr, FILE *pci_f) +unsigned long i810_addr(char **buff_ptr, size_t *len_ptr, FILE *pci_f) { char *p; - while (getline(buff_ptr, len_ptr, pci_f) > 0) + while (getline(buff_ptr, len_ptr, pci_f) > 0) { if (strstr(*buff_ptr, NONPRSTR) != NULL) { +#ifdef __NetBSD__ + assert(getline(buff_ptr, len_ptr, pci_f) > 0); +#endif p = strstr(*buff_ptr, MEMSTR); if (p != NULL) return strtoul(p+sizeof(MEMSTR), NULL, 16); } + } return 0; } @@@@ -316,10 +319,15 @@@@ int main (int argc, char *argv[]) { struct i810_par par; unsigned long addr; - int i, crt = -1, lcd = -1, probe = 0, err = 0, count = 0, chiptype, len = 0; + int i, crt = -1, lcd = -1, probe = 0, err = 0, count = 0, chiptype; + size_t len = 0; FILE *pci_f; char *buff = NULL; +#ifdef __NetBSD__ + char lspcistr[] = CMD_LSPCI " dump -d %d -f %d"; +#else char lspcistr[] = CMD_LSPCI " -v -d xxxx:xxxx"; +#endif char *chip; putenv("PATH=/sbin:/usr/sbin:/bin:/usr/bin"); @@@@ -357,7 +365,11 @@@@ int main (int argc, char *argv[]) } } - pci_f = popen(CMD_LSPCI " -n", "r"); + pci_f = popen(CMD_LSPCI +#ifdef __NetBSD__ + " list" +#endif + " -n", "r"); if (!pci_f) { fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); @@@@ -369,6 +381,19 @@@@ int main (int argc, char *argv[]) } pclose(pci_f); +#ifdef __NetBSD__ + { + char cmd[100]; + int dev = -1, fun = -1; + sscanf(chip, "000:%d:%d:", &dev, &fun); + if (dev == -1 || fun == -1) { + fprintf(stderr, "CMD_LSPCI is wrong.\n"); + exit(1); + } + snprintf(cmd, sizeof(cmd), lspcistr, dev, fun); + pci_f = popen(cmd, "r"); + } +#else { char *p = strstr(lspcistr, "xxxx:xxxx"); if (p == 0) { @@@@ -376,9 +401,10 @@@@ int main (int argc, char *argv[]) exit(1); } memcpy(p, chip, 9); + pci_f = popen(lspcistr, "r"); } +#endif - pci_f = popen(lspcistr, "r"); if (!pci_f) { fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); @ 1.1 log @Utility to switch on and off the lcd and external crt for intel 8xx graphics chips. @ text @d1 4 a4 3 $NetBSD$ --- i810switch.c 2005-06-12 00:36:36.000000000 -0400 +++ i810switch.c 2006-12-03 23:12:44.000000000 -0500 d22 1 a22 1 @@@@ -49,19 +54,31 @@@@ d66 6 a71 1 @@@@ -247,43 +264,25 @@@@ d131 4 a134 1 @@@@ -293,12 +292,16 @@@@ d152 7 a158 2 @@@@ -319,7 +322,11 @@@@ int i, crt = -1, lcd = -1, probe = 0, err = 0, count = 0, chiptype, len = 0; d169 1 a169 1 @@@@ -357,7 +364,11 @@@@ d182 1 a182 1 @@@@ -369,6 +380,19 @@@@ d202 1 a202 1 @@@@ -376,16 +400,17 @@@@ a213 8 } addr = i810_addr(&buff, &len, pci_f); if (addr == 0) { - fprintf(stderr, "Something is wrong with lspci.\n"); + fprintf(stderr, "Something is wrong with lspci.\n"); exit(1); } pclose(pci_f); @