apmd performance mode patch
Hi, I've just found that when using apmd with automatic performance mode without battery connected, performance is set to minimum. I often detach my battery when using AC for a long time. It's easier for me to have highest performance when AC without battery and 'apm -H'. I'm proposing patch that will do aditional check if there's battery and if it's absent increase performance up to 100%. This is simple solution which I'm using and I think that it's good extention for automatic performance mode. Cheers, pmp Index: apmd.c === RCS file: /cvs/src/usr.sbin/apmd/apmd.c,v retrieving revision 1.55 diff -u -r1.55 apmd.c --- apmd.c 30 Mar 2010 17:42:05 - 1.55 +++ apmd.c 1 Apr 2010 15:15:04 - @@ -320,9 +320,11 @@ case PERF_AUTO: /* * force setperf towards the max if we are connected to AC -* power and have a battery life greater than 15% +* power and have a battery life greater than 15% or +* battery is absent */ - if (pinfo-ac_state == APM_AC_ON pinfo-battery_life 15) + if (pinfo-ac_state == APM_AC_ON pinfo-battery_life 15 + || pinfo-battery_state == APM_BATTERY_ABSENT) forcehi = 1; break; case PERF_COOL:
audioctl minor fix
Hi, I was playing with audioctl and found that: - fullduplex and full_duplex are the same so one of them is redundant - output is different from other *ctl tools So I've decide to fix that and here is my attempt. I would be grateful for any comments. Cheers, pmp [demime 1.01d removed an attachment of type text/x-patch]
Re: audioctl minor fix
On Thu, 22 Oct 2009 22:33:23 +0200 Pawlowski Marcin Piotr pawlowski...@gmail.com wrote: Hi, I was playing with audioctl and found that: - fullduplex and full_duplex are the same so one of them is redundant - output is different from other *ctl tools So I've decide to fix that and here is my attempt. I would be grateful for any comments. Cheers, pmp [demime 1.01d removed an attachment of type text/x-patch] Oops... No attachment. --- audioctl.c.orig Sun Oct 18 12:13:07 2009 +++ audioctl.c Thu Oct 22 21:59:53 2009 @@ -85,7 +85,6 @@ { encodings, encbuf, STRING, READONLY }, { properties, properties,PROPS, READONLY }, { full_duplex,fullduplex,UINT, 0 }, - { fullduplex, fullduplex, UINT, 0 }, { blocksize, info.blocksize, UINT, 0 }, { hiwat, info.hiwat, UINT, 0 }, { lowat, info.lowat, UINT, 0 }, @@ -284,6 +283,30 @@ p-flags |= SET; } +cpfield(struct field *p, struct field *q) +{ + int i; + u_int u; + + /* Copy only what is necessary */ + + p-format = q-format; + p-flags = q-flags; + + switch (p-format) { + case ENC: + case UINT: + case XINT: + memcpy(p-valp, q-valp, sizeof(unsigned int)); + break; + case UCHAR: + memcpy(p-valp, q-valp, sizeof(u_char)); + break; + default: + errx(1, Invalid copy format.); + } +} + void getinfo(int fd) { @@ -335,7 +358,7 @@ int fd, i, ch; int aflag = 0, canwrite, writeinfo = 0; struct stat dstat, ostat; - struct field *p; + struct field *p, old; const char *file; const char *sep = =; @@ -399,26 +422,39 @@ } else { while (argc--) { char *q; - if ((q = strchr(*argv, '=')) != NULL) { *q++ = 0; p = findfield(*argv); if (p == 0) - warnx(field `%s' does not exist, *argv); + warnx(field `%s' does not exist, + *argv); else { if (!canwrite) errx(1, %s: permission denied, *argv); if (p-flags READONLY) - warnx(`%s' is read only, *argv); + warnx(`%s' is read only, + *argv); else { + cpfield(old, p); rdfield(p, q); if (p-valp == fullduplex) - if (ioctl(fd, AUDIO_SETFD, + if (ioctl(fd, + AUDIO_SETFD, fullduplex) 0) - err(1, set failed); + err(1, + set failed); } - writeinfo = 1; + if (ioctl(fd, AUDIO_SETINFO, info) 0) + err(1, set failed); + getinfo(fd); + if (p-flags SET) { + fprintf(out, %s: , p-name); + prfield(old, 0); + fprintf(out, - ); + prfield(p, 0); + fprintf(out, \n); + } } } else { p = findfield(*argv); @@ -430,18 +466,6 @@ } } argv++; - } - if (writeinfo ioctl(fd, AUDIO_SETINFO, info) 0) - err(1, set failed); - if (sep) { - getinfo(fd); - for (i = 0; fields[i].name; i++) { - if (fields[i].flags SET) { - fprintf(out, %s: - , fields[i].name); - prfield(fields[i], 0); - fprintf(out, \n); - } - } } } exit(0);
Re: audioctl minor fix
On Thu, 22 Oct 2009 21:41:45 + Jacob Meuser jake...@sdf.lonestar.org wrote: On Thu, Oct 22, 2009 at 11:02:37PM +0200, Pawlowski Marcin Piotr wrote: On Thu, 22 Oct 2009 22:33:23 +0200 Pawlowski Marcin Piotr pawlowski...@gmail.com wrote: Hi, I was playing with audioctl and found that: - fullduplex and full_duplex are the same so one of them is redundant so? did you consider that scripts may use one form and not the other? did you look at the commit history? I did looked at commit history but didn't found any info about why. I will look at scripts and try to find any references of that. - output is different from other *ctl tools $ sudo sysctl -n kern.usermount=1 1 $ audioctl -n play.rate=44100 $ mixerctl -n outputs.master=200 outputs.master: 200,200 - 200,200 imo, that is a much more important inconsistency. Done. --- audioctl.c.orig Sun Oct 18 12:13:07 2009 +++ audioctl.c Fri Oct 23 00:25:05 2009 @@ -284,6 +284,30 @@ p-flags |= SET; } +cpfield(struct field *p, struct field *q) +{ + int i; + u_int u; + + /* Copy only what is necessary */ + + p-format = q-format; + p-flags = q-flags; + + switch (p-format) { + case ENC: + case UINT: + case XINT: + memcpy(p-valp, q-valp, sizeof(unsigned int)); + break; + case UCHAR: + memcpy(p-valp, q-valp, sizeof(u_char)); + break; + default: + errx(1, Invalid copy format.); + } +} + void getinfo(int fd) { @@ -335,7 +359,7 @@ int fd, i, ch; int aflag = 0, canwrite, writeinfo = 0; struct stat dstat, ostat; - struct field *p; + struct field *p, old; const char *file; const char *sep = =; @@ -399,26 +423,42 @@ } else { while (argc--) { char *q; - if ((q = strchr(*argv, '=')) != NULL) { *q++ = 0; p = findfield(*argv); if (p == 0) - warnx(field `%s' does not exist, *argv); + warnx(field `%s' does not exist, + *argv); else { if (!canwrite) errx(1, %s: permission denied, *argv); if (p-flags READONLY) - warnx(`%s' is read only, *argv); + warnx(`%s' is read only, + *argv); else { + cpfield(old, p); rdfield(p, q); if (p-valp == fullduplex) - if (ioctl(fd, AUDIO_SETFD, + if (ioctl(fd, + AUDIO_SETFD, fullduplex) 0) - err(1, set failed); + err(1, + set failed); } - writeinfo = 1; + if (ioctl(fd, AUDIO_SETINFO, info) 0) + err(1, set failed); + getinfo(fd); + if (sep == 0) { + prfield(p, 0); + fprintf(out, \n); + } else if (p-flags SET) { + fprintf(out, %s: , p-name); + prfield(old, 0); + fprintf(out, - ); + prfield(p, 0); + fprintf(out, \n); + } } } else { p = findfield(*argv); @@ -430,18 +470,6 @@ } } argv++; - } - if (writeinfo ioctl(fd, AUDIO_SETINFO, info) 0) - err(1, set failed); - if (sep) { - getinfo