├── .gitignore ├── COPYING ├── Makefile.am ├── README.md ├── autogen.sh ├── clr-power-rfkill.service ├── clr-power-tweaks.conf.5 ├── clr-power.service ├── clr-power.timer ├── configure.ac ├── include ├── clr_power.h ├── pci-good.h └── usb-good.h ├── m4 └── .keep ├── man ├── clr-power-tweaks.conf.5 ├── clr-power-tweaks.conf.5.md ├── clr_power.1 └── clr_power.1.md ├── src ├── cpu.c ├── data.h ├── ethernet.c ├── gfx.c ├── lib.c ├── main.c ├── mm.c ├── pci.c ├── server.c ├── usb.c └── verifytime.c └── template /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .deps 3 | .dirstamp 4 | Makefile 5 | Makefile.in 6 | aclocal.m4 7 | autom4te.cache/ 8 | config.guess 9 | config.h 10 | config.h.in 11 | config.log 12 | config.status 13 | config.sub 14 | configure 15 | depcomp 16 | install-sh 17 | *.o 18 | libtool 19 | ltmain.sh 20 | m4/ 21 | missing 22 | stamp-h1 23 | DEADJOE 24 | test/ 25 | test 26 | clr_power 27 | *.tar.gz 28 | compile 29 | generated.c 30 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = clr_power 2 | clr_power_SOURCES = src/main.c src/lib.c src/pci.c src/ethernet.c src/usb.c src/gfx.c src/verifytime.c src/server.c src/cpu.c \ 3 | include/clr_power.h include/pci-good.h include/usb-good.h src/data.h src/mm.c 4 | 5 | AM_CPPFLAGS = -I$(top_srcdir)/include/ 6 | ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} 7 | 8 | systemdsystemunitdir = @SYSTEMD_SYSTEMUNITDIR@ 9 | systemdsystemunit_DATA = clr-power.service clr-power.timer clr-power-rfkill.service 10 | 11 | DISTCHECK_CONFIGURE_FLAGS = \ 12 | --with-systemdsystemunitdir=$(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) 13 | 14 | EXTRA_DIST = $(systemdsystemunit_DATA) man/clr_power.1.md man/clr-power-tweaks.conf.5.md 15 | 16 | dist_man_MANS = man/clr_power.1 man/clr-power-tweaks.conf.5 17 | 18 | docs: man/clr_power.1 man/clr-power-tweaks.conf.5 19 | 20 | man/clr_power.1: man/clr_power.1.md 21 | ronn -r $< --pipe > $@ 22 | 23 | man/clr-power-tweaks.conf.5: man/clr-power-tweaks.conf.5.md 24 | ronn -r $< --pipe > $@ 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## clr-power-tweaks 2 | 3 | This is a utility, authored for the purposes of Clear Linux, that sets 4 | reasonable power management defaults for platform devices. This is to improve 5 | energy efficiency while platform is idle. 6 | 7 | 8 | ## Contact 9 | 10 | Mailing list, Forums, IRC (freenode), source code repositories, direct e-mail 11 | information, as well as guidance for how to contribute to the Clear Linux 12 | project are maintained at our project website: 13 | * https://clearlinux.org/about 14 | 15 | 16 | ## Building 17 | 18 | To compile this project, run `sh autogen.sh` followed by `make`. The program 19 | has no significant dependencies and uses `glibc`. To install the unit file, 20 | it needs `systemd.pc` from the `systemd` package. 21 | 22 | 23 | # License 24 | 25 | ``` 26 | Copyright (C) 2012-2019 Intel Corporation 27 | 28 | This program is free software: you can redistribute it and/or modify 29 | it under the terms of the GNU General Public License as published by 30 | the Free Software Foundation, version 3 of the License. 31 | 32 | This program is distributed in the hope that it will be useful, 33 | but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | GNU General Public License for more details. 36 | 37 | You should have received a copy of the GNU General Public License 38 | along with this program. If not, see . 39 | ``` 40 | 41 | (The COPYING file has a full copy of the License.) 42 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig 6 | 7 | autoreconf --force --install --symlink --warnings=all 8 | 9 | args="\ 10 | --sysconfdir=/etc \ 11 | --localstatedir=/var \ 12 | --prefix=/usr \ 13 | --enable-silent-rules" 14 | 15 | if test -z "${NOCONFIGURE}"; then 16 | set -x 17 | ./configure CFLAGS='-g -O0' $args "$@" 18 | make clean 19 | fi 20 | -------------------------------------------------------------------------------- /clr-power-rfkill.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Rfkill bluetooth controllers on first boot 3 | After=sysinit.target 4 | ConditionFileIsExecutable=/usr/bin/rfkill 5 | ConditionPathExists=/dev/rfkill 6 | ConditionFirstBoot=true 7 | ConditionVirtualization=!container 8 | 9 | [Service] 10 | Type=oneshot 11 | ExecStart=/usr/bin/rfkill block bluetooth 12 | -------------------------------------------------------------------------------- /clr-power-tweaks.conf.5: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "CLR\-POWER\-TWEAKS" "5" "February 2020" "" "" 5 | . 6 | .SH "NAME" 7 | \fBclr\-power\-tweaks\fR 8 | -------------------------------------------------------------------------------- /clr-power.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Clear Linux Project for Intel Architecture power tweaks 3 | After=sysinit.target 4 | ConditionVirtualization=!container 5 | 6 | [Service] 7 | Type=oneshot 8 | ExecStart=/usr/bin/clr_power 9 | -------------------------------------------------------------------------------- /clr-power.timer: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Apply Clear Linux Project for Intel Architecture power tweaks after boot 3 | ConditionVirtualization=!container 4 | 5 | [Timer] 6 | OnStartupSec=10 7 | AccuracySec=3 8 | 9 | [Install] 10 | WantedBy=timers.target 11 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.69]) 5 | AC_INIT([clr-power-tweaks],[220],[dev@lists.clearlinux.org]) 6 | AM_INIT_AUTOMAKE([foreign -Wall -Wextra-portability subdir-objects]) 7 | AM_SILENT_RULES([yes]) 8 | AC_CONFIG_MACRO_DIRS([m4]) 9 | 10 | AC_LANG(C) 11 | 12 | # Checks for programs. 13 | AC_PROG_CXX 14 | AC_PROG_AWK 15 | AC_PROG_CC 16 | AC_PROG_CPP 17 | AC_PROG_INSTALL 18 | AC_PROG_LN_S 19 | AC_PROG_MAKE_SET 20 | AC_PROG_RANLIB 21 | 22 | # Checks for libraries. 23 | 24 | # Checks for header files. 25 | AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h time.h argp.h glob.h]) 26 | 27 | # Checks for typedefs, structures, and compiler characteristics. 28 | AC_CHECK_HEADER_STDBOOL 29 | AC_TYPE_SIZE_T 30 | 31 | # Checks for library functions. 32 | AC_CHECK_FUNCS([memset socket strstr strdup strerror strtoul strtoull clock_gettime]) 33 | 34 | 35 | AC_CONFIG_HEADERS([config.h]) 36 | 37 | PKG_CHECK_MODULES([SYSTEMD], [systemd]) 38 | 39 | AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],[path to systemd system service directory]), [path_systemdsystemunit=${withval}], 40 | [path_systemdsystemunit="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`"]) 41 | if (test -n "${path_systemdsystemunit}"); then 42 | SYSTEMD_SYSTEMUNITDIR="${path_systemdsystemunit}" 43 | AC_SUBST(SYSTEMD_SYSTEMUNITDIR) 44 | fi 45 | 46 | AC_CONFIG_FILES([Makefile]) 47 | 48 | AC_OUTPUT 49 | -------------------------------------------------------------------------------- /include/clr_power.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef __INCLUDE_GUARD_CLR_POWER_H__ 4 | #define __INCLUDE_GUARD_CLR_POWER_H__ 5 | 6 | struct pci_ids { 7 | unsigned int vendor; 8 | unsigned int device; 9 | }; 10 | 11 | struct usb_dev { 12 | unsigned int vendor; 13 | unsigned int device; 14 | unsigned int class; 15 | }; 16 | 17 | extern void lib_init(const bool dbg); 18 | extern int write_string_to_file(const char *filename, const char *string); 19 | extern int write_string_to_files(const char *glob, const char *string); 20 | extern void string_exclude(const char *glob); 21 | extern void do_pci_pm(void); 22 | extern void do_WOL(void); 23 | extern void do_usb_pm(void); 24 | extern void do_gfx_pm(void); 25 | extern void do_cpu_pm(void); 26 | extern void verify_time(void); 27 | extern int is_server(void); 28 | extern void do_zero_pages(void); 29 | #endif 30 | -------------------------------------------------------------------------------- /include/pci-good.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This structure requires some maintenance on it. Specifically the host 3 | * controllers need to be listed before any of the devices. This allows the 4 | * clear tweaks to operate on a host controller first then a device for 5 | * enabling config space changes (for example). 6 | */ 7 | const static struct pci_ids known_good[] = 8 | { 9 | /* 10 | * Host Controllers 11 | */ 12 | { 0x1b73, 0x1009}, /* Fresco Logic xHCI Controller */ 13 | { 0x8086, 0x0104}, /* 2nd Gen Core DRAM Controller */ 14 | { 0x8086, 0x0116}, /* 2nd Gen Core Integrated Graphics Processor */ 15 | { 0x8086, 0x0153}, /* 3rd Gen Core Thermal Subsystem */ 16 | { 0x8086, 0x0154}, /* 3rd Gen Core DRAM Controller */ 17 | { 0x8086, 0x0166}, /* 3rd Gen Core Graphics Controller */ 18 | { 0x8086, 0x0a04}, /* HSW-U DRAM Controller */ 19 | { 0x8086, 0x0a0c}, /* HSW-U HD Audio Controller */ 20 | { 0x8086, 0x0a26}, /* Haswell-ULT Integrated Graphics Controller */ 21 | { 0x8086, 0x0f00}, /* VLV SSA-CUnit */ 22 | { 0x8086, 0x0f18}, /* VLV SEC */ 23 | { 0x8086, 0x0f1c}, /* VLV PCU */ 24 | { 0x8086, 0x0f31}, /* VLV PCI Generation 7 */ 25 | { 0x8086, 0x0f35}, /* VLV USB xHCI Host Controller */ 26 | { 0x8086, 0x156f}, /* Intel Corporation Ethernet Connection I219-LM */ 27 | { 0x8086, 0x1570}, /* Intel Corporation Ethernet Connection I219-V */ 28 | { 0x8086, 0x15a3}, /* Ethernet controller: Intel Corporation Ethernet Connection (3) I218-V */ 29 | { 0x8086, 0x15d8}, /* Ethernet controller: Intel Corporation Ethernet Connection (3) I218-V */ 30 | { 0x8086, 0x1604}, /* Host bridge: Intel Corporation Broadwell-U Host Bridge -OPI */ 31 | { 0x8086, 0x160c}, /* Audio device: Intel Corporation Broadwell-U Audio Controller */ 32 | { 0x8086, 0x162b}, /* VGA compatible controller: Intel Corporation Broadwell-U Integrated Graphics */ 33 | { 0x8086, 0x1904}, /* Intel Corporation Skylake Host Bridge/DRAM Registers */ 34 | { 0x8086, 0x1911}, /* System peripheral: Intel Corporation Skylake Gaussian Mixture Model */ 35 | { 0x8086, 0x1926}, /* Intel Corporation Skylake Integrated Graphics */ 36 | { 0x8086, 0x1c03}, /* 6Series SATA AHCI Controller */ 37 | { 0x8086, 0x1c10}, /* 6Series PCI Express Root Port 1 */ 38 | { 0x8086, 0x1c12}, /* 6Series PCI Express Root Port 2 */ 39 | { 0x8086, 0x1c16}, /* 6Series PCI Express Root Port 4 */ 40 | { 0x8086, 0x1c20}, /* 6Series HD Audio Controller */ 41 | { 0x8086, 0x1c22}, /* 6Series SMBus Controller */ 42 | { 0x8086, 0x1c26}, /* 6Series USB Enhanced Host Controller 1 */ 43 | { 0x8086, 0x1c3a}, /* 6Series MEI Controller */ 44 | { 0x8086, 0x1c4d}, /* QS67 Express LPC Controller */ 45 | { 0x8086, 0x1e03}, /* 7Series SATA Controller AHCI */ 46 | { 0x8086, 0x1e10}, /* 7Series PCI Express Root Port 1 */ 47 | { 0x8086, 0x1e12}, /* 7Series PCI Express Root Port 2 */ 48 | { 0x8086, 0x1e20}, /* 7Series HD Audio Controller */ 49 | { 0x8086, 0x1e22}, /* 7Series SMBus Controller */ 50 | { 0x8086, 0x1e24}, /* 7Series Thermal Management Controller */ 51 | { 0x8086, 0x1e26}, /* 7Series USB Enhanced Host Controller 1 */ 52 | { 0x8086, 0x1e2d}, /* 7Series USB Enhanced Host Controller 2 */ 53 | { 0x8086, 0x1e3a}, /* 7Series MEI Controller */ 54 | { 0x8086, 0x1e59}, /* HM76 Express Chipset LPC Controller */ 55 | { 0x8086, 0x24f3}, /* Intel Corporation Wireless 8260 */ 56 | { 0x8086, 0x2921}, /* ICH9 SATA Controller IDE */ 57 | { 0x8086, 0x2934}, /* ICH9 USB UCHI Controller 1 */ 58 | { 0x8086, 0x2935}, /* ICH9 USB UCHI Controller 2 */ 59 | { 0x8086, 0x2936}, /* ICH9 USB UHCI Controller 3 */ 60 | { 0x8086, 0x2937}, /* ICH9 USB UCHI Controller 4 */ 61 | { 0x8086, 0x2938}, /* ICH9 USB UHCI Controller 5 */ 62 | { 0x8086, 0x2939}, /* ICH9 USB UHCI Controller 6 */ 63 | { 0x8086, 0x293a}, /* ICH9 USB2 ECHI Controller */ 64 | { 0x8086, 0x293c}, /* ICH9 HD Audio Controller */ 65 | { 0x8086, 0x3406}, /* 5520 IO Hub to ESI Port */ 66 | { 0x8086, 0x3408}, /* 5520 IO Hub PCI Express Root Port 1 */ 67 | { 0x8086, 0x340a}, /* 5520 IO Hub PCI Express Root Port 3 */ 68 | { 0x8086, 0x340b}, /* 5520 IO Hub PCI Express Root Port 4 */ 69 | { 0x8086, 0x340c}, /* 5520 IO Hub PCI Express Root Port 5 */ 70 | { 0x8086, 0x340e}, /* 5520 IO Hub PCI Express Root Port 7 */ 71 | { 0x8086, 0x3410}, /* 7500 IO Hub PCI Express Root Port 9 */ 72 | { 0x8086, 0x3411}, /* 7500 IO Hub PCI Express Root Port 10 */ 73 | { 0x8086, 0x5926}, /* 7500 IO Hub PCI Express Root Port 10 */ 74 | { 0x8086, 0x9c03}, /* LPT-LP SATA Contoller (AHCI */ 75 | { 0x8086, 0x9c10}, /* LPT-LP PCI Express Root Port 1 */ 76 | { 0x8086, 0x9c20}, /* LPT-LP HD Audio Controller */ 77 | { 0x8086, 0x9c22}, /* LPT-LP SMBus Controller */ 78 | { 0x8086, 0x9c26}, /* LPT-LP USB EHCI */ 79 | { 0x8086, 0x9c31}, /* LPT-LP USB xHCI HC */ 80 | { 0x8086, 0x9c3a}, /* LPT-LP HECI 0 */ 81 | { 0x8086, 0x9c43}, /* LPC Controller */ 82 | { 0x8086, 0x9c5a}, /* Network controller: Intel Corporation Wireless 7265 (rev 59) */ 83 | { 0x8086, 0x9c83}, /* SATA controller: Intel Corporation Wildcat Point-LP SATA Controller {AHCI Mode} */ 84 | { 0x8086, 0x9c90}, /* PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #1 */ 85 | { 0x8086, 0x9c96}, /* PCI bridge: Intel Corporation Wildcat Point-LP PCI Express Root Port #4 */ 86 | { 0x8086, 0x9ca0}, /* Audio device: Intel Corporation Wildcat Point-LP High Definition Audio Controller */ 87 | { 0x8086, 0x9ca2}, /* SMBus: Intel Corporation Wildcat Point-LP SMBus Controller (rev 03) */ 88 | { 0x8086, 0x9ca6}, /* USB controller: Intel Corporation Wildcat Point-LP USB EHCI Controller */ 89 | { 0x8086, 0x9cba}, /* Communication controller: Intel Corporation Wildcat Point-LP MEI Controller #1 */ 90 | { 0x8086, 0x9cc3}, /* ISA bridge: Intel Corporation Wildcat Point-LP LPC Controller */ 91 | { 0x8086, 0x9d03}, /* Intel Corporation Sunrise Point-LP SATA Controller {AHCI mode} */ 92 | { 0x8086, 0x9d14}, /* Intel Corporation Sunrise Point-LP PCI Express Root Port #5 */ 93 | { 0x8086, 0x9d21}, /* Intel Corporation Sunrise Point-LP PMC */ 94 | { 0x8086, 0x9d23}, /* Intel Corporation Sunrise Point-LP SMBus */ 95 | { 0x8086, 0x9d27}, /* Intel Corporation Sunrise Point-LP Serial IO UART Controller #0 */ 96 | { 0x8086, 0x9d2d}, /* Intel Corporation Sunrise Point-LP Secure Digital IO Controller */ 97 | { 0x8086, 0x9d2f}, /* Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller */ 98 | { 0x8086, 0x9d31}, /* Intel Corporation Sunrise Point-LP Thermal subsystem */ 99 | { 0x8086, 0x9d3a}, /* Intel Corporation Sunrise Point-LP CSME HECI #1 */ 100 | { 0x8086, 0x9d3d}, /* Intel Corporation Sunrise Point-LP Active Management Technology */ 101 | { 0x8086, 0x9d48}, /* Intel Corporation Sunrise Point-LP LPC Controller */ 102 | { 0x8086, 0x9d4e}, /* Intel Corporation Sunrise Point-LP LPC Controller */ 103 | { 0x8086, 0x9d70}, /* Intel Corporation Sunrise Point-LP HD Audio */ 104 | { 0x8086, 0xa13a}, /* Communication controller: Intel Corporation Sunrise Point-H CSME HECI #1 */ 105 | { 0x8086, 0xa110}, /* PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 */ 106 | { 0x8086, 0xa111}, /* PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 */ 107 | { 0x8086, 0xa112}, /* PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 */ 108 | { 0x8086, 0xa114}, /* PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 */ 109 | { 0x8086, 0xa118}, /* PCI bridge: Intel Corporation Sunrise Point-H PCI Express Root Port #1 */ 110 | { 0x8086, 0xa14e}, /* ISA bridge: Intel Corporation Sunrise Point-H LPC Controller */ 111 | { 0x8086, 0xa121}, /* Memory controller: Intel Corporation Sunrise Point-H PMC */ 112 | { 0x8086, 0xa170}, /* Audio device: Intel Corporation Sunrise Point-H HD Audio */ 113 | { 0x8086, 0xa123}, /* SMBus: Intel Corporation Sunrise Point-H SMBus */ 114 | { 0x8086, 0x15b7}, /* Ethernet controller: Intel Corporation Ethernet Connection (2) I219-LM */ 115 | { 0x8086, 0x24f3}, /* Network controller: Intel Corporation Wireless 8260 */ 116 | { 0x8086, 0x1910}, /* Intel Corporation Skylake Host Bridge/DRAM Registers */ 117 | { 0x8086, 0x193b}, /* Intel Corporation Iris Pro Graphics 580 */ 118 | { 0x8086, 0xa131}, /* Intel Corporation Sunrise Point-H Thermal subsystem */ 119 | { 0x8086, 0xa12f}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 120 | { 0x8086, 0x590c}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 121 | { 0x8086, 0x591e}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 122 | { 0x8086, 0x9d43}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 123 | { 0x8086, 0x9d43}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 124 | { 0x8086, 0x9d48}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 125 | { 0x8086, 0x9d56}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 126 | { 0x8086, 0x9d58}, /* Intel Corporation Sunrise Point-H USB 3.0 xHCI Controller */ 127 | 128 | { 0x8086, 0x3e34}, /* WHL root bridge */ 129 | 130 | { 0x8086, 0x5914}, /* KBL-R root bridge */ 131 | { 0x8086, 0x5917}, /* KBL-R gfx */ 132 | 133 | { 0x8086, 0x5904}, /* KBL root bridge */ 134 | { 0x8086, 0x5916}, /* KBL gfx */ 135 | { 0x8086, 0x1903}, /* KBL thermal */ 136 | { 0x8086, 0x9d2f}, /* KBL USB */ 137 | { 0x8086, 0x9d31}, /* KBL Audio */ 138 | { 0x8086, 0x9d60}, /* KBL I2C */ 139 | { 0x8086, 0x9d61}, /* KBL I2C */ 140 | { 0x8086, 0x9d3a}, /* KBL HECI */ 141 | { 0x8086, 0x9d10}, /* KBL PCI bridge */ 142 | { 0x8086, 0x9d14}, /* KBL PCI root port */ 143 | { 0x8086, 0x9d15}, /* KBL PCI root port */ 144 | { 0x8086, 0x9d18}, /* KBL PCI root port */ 145 | { 0x8086, 0x9d58}, /* KBL ISA */ 146 | { 0x8086, 0x9d21}, /* KBL MEM */ 147 | { 0x8086, 0x9d71}, /* KBL Audio */ 148 | { 0x8086, 0x9d23}, /* KBL SMBus */ 149 | 150 | { 0x8086, 0x591f}, /* KBL root bridge */ 151 | { 0x8086, 0x5912}, /* KBL gfx */ 152 | { 0x8086, 0x5927}, /* KBL gfx */ 153 | { 0x8086, 0xa2af}, /* KBL USB */ 154 | { 0x8086, 0xa2ba}, /* KBL root bridge */ 155 | { 0x8086, 0xa282}, /* KBL gfx */ 156 | { 0x8086, 0xa2e7}, /* KBL USB */ 157 | { 0x8086, 0xa290}, /* KBL root bridge */ 158 | { 0x8086, 0xa297}, /* KBL gfx */ 159 | { 0x8086, 0xa298}, /* KBL USB */ 160 | { 0x8086, 0xa2c5}, /* KBL root bridge */ 161 | { 0x8086, 0xa2a1}, /* KBL gfx */ 162 | { 0x8086, 0xa2f0}, /* KBL USB */ 163 | { 0x8086, 0xa2a3}, /* KBL root bridge */ 164 | 165 | { 0x8086, 0xa282}, /* Core i9 sata */ 166 | { 0x8086, 0xa2af}, /* Core i9 xhci */ 167 | { 0x8086, 0xa2af}, /* Core i9 xhci */ 168 | { 0x8086, 0xa2f0}, /* Core i9 audio */ 169 | { 0x8086, 0xa298}, /* Core i9 PCI */ 170 | { 0x8086, 0xa298}, /* Core i9 PCI */ 171 | { 0x8086, 0xa294}, /* Core i9 PCI */ 172 | { 0x8086, 0xa290}, /* Core i9 PCI */ 173 | { 0x8086, 0xa2e7}, /* Core i9 PCI */ 174 | { 0x8086, 0x2030}, /* Core i9 PCI */ 175 | 176 | { 0x8086, 0x5af0}, /* Apollo lake PCI */ 177 | { 0x8086, 0x5a8c}, /* Apollo lake PCI */ 178 | { 0x8086, 0x5a85}, /* Apollo lake PCI */ 179 | { 0x8086, 0x5a98}, /* Apollo lake PCI */ 180 | { 0x8086, 0x5a9a}, /* Apollo lake PCI */ 181 | { 0x8086, 0x5ae3}, /* Apollo lake PCI */ 182 | { 0x8086, 0x5ad8}, /* Apollo lake PCI */ 183 | { 0x8086, 0x5ad9}, /* Apollo lake PCI */ 184 | { 0x8086, 0x5aa8}, /* Apollo lake PCI */ 185 | { 0x8086, 0x5ac8}, /* Apollo lake PCI */ 186 | { 0x8086, 0x5acc}, /* Apollo lake PCI */ 187 | { 0x8086, 0x5ae8}, /* Apollo lake PCI */ 188 | { 0x8086, 0x5ad4}, /* Apollo lake PCI */ 189 | { 0x8086, 0x3165}, /* Apollo lake PCI */ 190 | 191 | { 0x8086, 0x15b8}, /* SKX */ 192 | { 0x8086, 0x2014}, /* SKX */ 193 | { 0x8086, 0x2015}, /* SKX */ 194 | { 0x8086, 0x2016}, /* SKX */ 195 | { 0x8086, 0x2018}, /* SKX */ 196 | { 0x8086, 0x2020}, /* SKX */ 197 | { 0x8086, 0x2021}, /* SKX */ 198 | { 0x8086, 0x2024}, /* SKX */ 199 | { 0x8086, 0x2025}, /* SKX */ 200 | { 0x8086, 0x2026}, /* SKX */ 201 | { 0x8086, 0x2030}, /* SKX */ 202 | { 0x8086, 0x2034}, /* SKX */ 203 | { 0x8086, 0x2035}, /* SKX */ 204 | { 0x8086, 0x2036}, /* SKX */ 205 | { 0x8086, 0x2040}, /* SKX */ 206 | { 0x8086, 0x2041}, /* SKX */ 207 | { 0x8086, 0x2042}, /* SKX */ 208 | { 0x8086, 0x2043}, /* SKX */ 209 | { 0x8086, 0x2044}, /* SKX */ 210 | { 0x8086, 0x2045}, /* SKX */ 211 | { 0x8086, 0x2046}, /* SKX */ 212 | { 0x8086, 0x2047}, /* SKX */ 213 | { 0x8086, 0x2048}, /* SKX */ 214 | { 0x8086, 0x2049}, /* SKX */ 215 | { 0x8086, 0x204a}, /* SKX */ 216 | { 0x8086, 0x204b}, /* SKX */ 217 | { 0x8086, 0x204c}, /* SKX */ 218 | { 0x8086, 0x204d}, /* SKX */ 219 | { 0x8086, 0x204e}, /* SKX */ 220 | { 0x8086, 0x2054}, /* SKX */ 221 | { 0x8086, 0x2055}, /* SKX */ 222 | { 0x8086, 0x2056}, /* SKX */ 223 | { 0x8086, 0x2057}, /* SKX */ 224 | { 0x8086, 0x2066}, /* SKX */ 225 | { 0x8086, 0x2080}, /* SKX */ 226 | { 0x8086, 0x2081}, /* SKX */ 227 | { 0x8086, 0x2082}, /* SKX */ 228 | { 0x8086, 0x2083}, /* SKX */ 229 | { 0x8086, 0x2084}, /* SKX */ 230 | { 0x8086, 0x2085}, /* SKX */ 231 | { 0x8086, 0x2086}, /* SKX */ 232 | { 0x8086, 0x208d}, /* SKX */ 233 | { 0x8086, 0x208e}, /* SKX */ 234 | { 0x8086, 0xa290}, /* SKX */ 235 | { 0x8086, 0xa294}, /* SKX */ 236 | { 0x8086, 0xa298}, /* SKX */ 237 | { 0x8086, 0xa2a1}, /* SKX */ 238 | { 0x8086, 0xa2a3}, /* SKX */ 239 | { 0x8086, 0xa2af}, /* SKX */ 240 | { 0x8086, 0xa2ba}, /* SKX */ 241 | { 0x8086, 0xa2d2}, /* SKX */ 242 | { 0x8086, 0xa2e7}, /* SKX */ 243 | { 0x8086, 0xa2f0}, /* SKX */ 244 | 245 | { 0x8086, 0x0412}, 246 | { 0x8086, 0x0c00}, 247 | { 0x8086, 0x0c0c}, 248 | { 0x8086, 0x153a}, 249 | { 0x8086, 0x8c18}, 250 | { 0x8086, 0x8c1c}, 251 | { 0x8086, 0x8c20}, 252 | { 0x8086, 0x8c22}, 253 | { 0x8086, 0x8c26}, 254 | { 0x8086, 0x8c2d}, 255 | { 0x8086, 0x8c31}, 256 | { 0x8086, 0x8c3a}, 257 | { 0x8086, 0x8c3d}, 258 | 259 | { 0x8086, 0x3ea0 }, /* WHL */ 260 | 261 | { 0x8086, 0x3ecc }, /* CFL */ 262 | { 0x8086, 0x3ea5 }, /* CFL */ 263 | { 0x8086, 0x1911 }, /* CFL */ 264 | { 0x8086, 0x9df9 }, /* CFL */ 265 | { 0x8086, 0x9ded }, /* CFL */ 266 | { 0x8086, 0x9def }, /* CFL */ 267 | { 0x8086, 0x9df0 }, /* CFL */ 268 | { 0x8086, 0x9de0 }, /* CFL */ 269 | { 0x8086, 0x9dd3 }, /* CFL */ 270 | { 0x8086, 0x9db8 }, /* CFL */ 271 | { 0x8086, 0x9dbc }, /* CFL */ 272 | { 0x8086, 0x9db0 }, /* CFL */ 273 | { 0x8086, 0x9db6 }, /* CFL */ 274 | { 0x8086, 0x9d84 }, /* CFL */ 275 | { 0x8086, 0x9dc8 }, /* CFL */ 276 | { 0x8086, 0x9da3 }, /* CFL */ 277 | { 0x8086, 0x9da4 }, /* CFL */ 278 | { 0x8086, 0x15da }, /* CFL */ 279 | { 0x8086, 0x15da }, /* CFL */ 280 | { 0x8086, 0x15db }, /* CFL */ 281 | 282 | { 0x8086, 0x8a12 }, 283 | { 0x8086, 0x8a5a }, 284 | { 0x8086, 0x8a03 }, 285 | { 0x8086, 0x8a19 }, 286 | { 0x8086, 0x8a1d }, 287 | { 0x8086, 0x8a1f }, 288 | { 0x8086, 0x8a21 }, 289 | { 0x8086, 0x8a23 }, 290 | { 0x8086, 0x8a11 }, 291 | { 0x8086, 0x8a13 }, 292 | { 0x8086, 0x8a17 }, 293 | { 0x8086, 0x8a0d }, 294 | { 0x8086, 0x34fc }, 295 | { 0x8086, 0x34ed }, 296 | { 0x8086, 0x34ef }, 297 | { 0x8086, 0x34f0 }, 298 | { 0x8086, 0x34f8 }, 299 | { 0x8086, 0x34e8 }, 300 | { 0x8086, 0x34e9 }, 301 | { 0x8086, 0x34ea }, 302 | { 0x8086, 0x34eb }, 303 | { 0x8086, 0x34e0 }, 304 | { 0x8086, 0x34e4 }, 305 | { 0x8086, 0x34d3 }, 306 | { 0x8086, 0x34c5 }, 307 | { 0x8086, 0x34c6 }, 308 | { 0x8086, 0x34c4 }, 309 | { 0x8086, 0x34b0 }, 310 | { 0x8086, 0x34a8 }, 311 | { 0x8086, 0x34ab }, 312 | { 0x8086, 0x3482 }, 313 | { 0x8086, 0x34c8 }, 314 | { 0x8086, 0x34a3 }, 315 | { 0x8086, 0x34a4 }, 316 | { 0x8086, 0x15e2 }, 317 | { 0x8086, 0xf1a5 }, 318 | { 0x8086, 0xf1a6 }, 319 | 320 | { 0x144d, 0xa800 }, /* CFL */ 321 | { 0x19ec, 0x522a}, /* CFL */ 322 | 323 | /* 324 | * Devices 325 | */ 326 | { 0x8086, 0x088e}, /* Centrino Advanced-N 6235 */ 327 | /* if 0x1559 is enabled, breaks wired network */ 328 | // { 0x8086, 0x1559}, /* Intel tehernet I218-U */ 329 | { 0x168c, 0x0032}, /* AR9580 Wireless Adapter */ 330 | { 0x14e4, 0x1639}, /* Broadcom BCM5709 Gigabit Ethernet */ 331 | { 0x1217, 0x8621}, /* SD Host controller: O2 Micro, Inc. SD/MMC Card Reader Controller */ 332 | //{ 0x144d, 0xa802}, /* Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM951/PM951 */ 333 | { 0x168c, 0x003e}, /* Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter */ 334 | { 0x10ec, 0x5229}, /* Realtek Semiconductor Co., Ltd. RTS5229 PCI Express Card Reader */ 335 | { 0x10ec, 0x525a}, /* Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader */ 336 | { 0x10ec, 0x5259}, /* Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader */ 337 | { 0x1179, 0x0115}, /* Toshiba NVME */ 338 | { 0x1179, 0x0116}, /* Toshiba NVME */ 339 | { 0x1179, 0x011a}, /* Toshiba NVME */ 340 | { 0x1b21, 0x2142}, /* ASMedia Technology Inc. Device */ 341 | { 0x10ec, 0x8168}, /* Realtek RTL8168 */ 342 | 343 | { 0xffff, 0xffff} }; 344 | 345 | -------------------------------------------------------------------------------- /include/usb-good.h: -------------------------------------------------------------------------------- 1 | const static struct usb_dev known_good[] = 2 | { 3 | /* {0x8087, 0x09fa, 0x0000} */ /* Intel Sensor Hub. Bust on USB autosusped */ 4 | {0x8087, 0x07dc, 0x0000}, 5 | {0x8087, 0x8001, 0x0009}, /* EHCI/XHCI built in hub */ 6 | {0x8087, 0x0a2a, 224}, 7 | {0x8087, 0x0a2b, 224}, 8 | /* BYT-T additions from T100 - need to verify they are all BYT-T systems */ 9 | {0x0b05, 0x17e0, 0x0000}, 10 | {0x0b95, 0x7720, 0x00ff}, 11 | {0x1d6b, 0x0002, 0x0009}, 12 | {0x1d6b, 0x0003, 0x0009}, 13 | /* BYT-T additions end */ 14 | /* Dell XPS 13 9360 (KBL) additions */ 15 | {0x04f3, 0x2234, 0x0000}, /* Elan HID-Touchscreen, needed for >PkgC8 */ 16 | /* Dell XPS 13 9360 (KBL) additions end */ 17 | {0xFFFF, 0xFFFF, 0} }; 18 | 19 | -------------------------------------------------------------------------------- /m4/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clearlinux/clr-power-tweaks/5115117735498e8184007e957ed4d3ad751f8c21/m4/.keep -------------------------------------------------------------------------------- /man/clr-power-tweaks.conf.5: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "CLR\-POWER\-TWEAKS" "5" "March 2020" "" "" 5 | . 6 | .SH "NAME" 7 | \fBclr\-power\-tweaks\fR 8 | . 9 | .SH "SYNOPSIS" 10 | \fB\fBclr\-power\-tweaks\.conf\fR\fR is an optional configuration file for the clr_power(1) utility\. 11 | . 12 | .P 13 | \fB/etc/clr\-power\-tweaks\.conf\fR 14 | . 15 | .SH "DESCRIPTION" 16 | \fB\fBclr\-power\-tweaks\.conf\fR\fR is an optional configuration file for the clr_power(1) utility\. The configuration file contains kernel and device parameter values used by the clr_power(1) utility\. 17 | . 18 | .P 19 | Configuration parameter values placed in \fB\fBclr\-power\-tweaks\.conf\fR\fR will supersede the built\-in defaults configured by clr_power(1)\. New parameters can be added to the configuration to supplement the built\-in values\. Built\-in parameters can be changed by defining them in \fB\fBclr\-power\-tweaks\.conf\fR\fR with a different value\. Parameters can be excluded from being modified by clr_power(1) by adding them in \fB\fBclr\-power\-tweaks\.conf\fR\fR without a value\. 20 | . 21 | .SH "FILE FORMAT" 22 | \fB\fBclr\-power\-tweaks\.conf\fR\fR uses a key\-value pairs to define parameter values\. 23 | . 24 | .P 25 | Each line contains one parameter\-value pair, delimited by a space character\. 26 | . 27 | .P 28 | Parameters are paths from the proc(5) filesystem\. Parameters paths can include glob(n) wildcards to match multiple paths\. 29 | . 30 | .P 31 | Acceptable values are determined by the parameter being set\. Any parameter listed in the configuration file without a value will be excluded by clr_power(1) and the parameter will inherit the kernel\'s built\-in default parameter value\. 32 | . 33 | .SH "EXAMPLES" 34 | . 35 | .IP "1." 4 36 | \fB\fBclr\-power\-tweaks\.conf\fR\fR entry to override the default value in clr_power(1) for CPU governor with \fBpowersave\fR\. All other values built\-in to clr_power(1) would still get applied\. 37 | . 38 | .IP 39 | Note the globbing used with \fB*\fR to target all CPU cores\. 40 | . 41 | .IP "" 4 42 | . 43 | .nf 44 | 45 | /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor powersave 46 | . 47 | .fi 48 | . 49 | .IP "" 0 50 | 51 | . 52 | .IP "2." 4 53 | \fB\fBclr\-power\-tweaks\.conf\fR\fR entry to exclude a parameter causing it to use the kernel\'s built\-in default value (60)\. All other values built\-in to clr_power(1) would still get applied\. 54 | . 55 | .IP 56 | Note the omission of a value\. 57 | . 58 | .IP "" 4 59 | . 60 | .nf 61 | 62 | /proc/sys/vm/swappiness 63 | . 64 | .fi 65 | . 66 | .IP "" 0 67 | 68 | . 69 | .IP "3." 4 70 | \fB\fBclr\-power\-tweaks\.conf\fR\fR entry to add two new parameters to increase UDP buffers All other values built\-in to clr_power(1) would still get applied\. 71 | . 72 | .IP "" 4 73 | . 74 | .nf 75 | 76 | /proc/sys/net/ipv4/udp_rmem_min 8192 77 | /proc/sys/net/ipv4/udp_wmem_min 8192 78 | . 79 | .fi 80 | . 81 | .IP "" 0 82 | 83 | . 84 | .IP "" 0 85 | . 86 | .SH "BUGS" 87 | The default clr\-power\-tweaks\.conf(5) aims to have reasonable defaults for achieving power and performance efficiency\. Default values may not be optimal for all systems and environments\. 88 | . 89 | .P 90 | See GitHub Issues: \fIhttps://github\.com/clearlinux/clr\-power\-tweaks/issues\fR 91 | . 92 | .SH "SEE ALSO" 93 | \fBclr_power\.conf(5)\fR, \fBproc(5)\fR, \fBsysctl(2)\fR 94 | . 95 | .P 96 | For parameters understood by the kernel, please see https://www\.kernel\.org/doc/html/latest/admin\-guide/kernel\-parameters\.html 97 | -------------------------------------------------------------------------------- /man/clr-power-tweaks.conf.5.md: -------------------------------------------------------------------------------- 1 | ## SYNOPSIS 2 | 3 | **`clr-power-tweaks.conf`** is an optional configuration file for the 4 | clr_power(1) utility. 5 | 6 | `/etc/clr-power-tweaks.conf` 7 | 8 | ## DESCRIPTION 9 | 10 | **`clr-power-tweaks.conf`** is an optional configuration file for the 11 | clr_power(1) utility. The configuration file contains kernel and device 12 | parameter values used by the clr_power(1) utility. 13 | 14 | Configuration parameter values placed in **`clr-power-tweaks.conf`** will 15 | supersede the built-in defaults configured by clr_power(1). New parameters can 16 | be added to the configuration to supplement the built-in values. Built-in 17 | parameters can be changed by defining them in **`clr-power-tweaks.conf`** with 18 | a different value. Parameters can be excluded from being modified by 19 | clr_power(1) by adding them in **`clr-power-tweaks.conf`** without a value. 20 | 21 | ## FILE FORMAT 22 | 23 | **`clr-power-tweaks.conf`** uses a key-value pairs to define parameter values. 24 | 25 | Each line contains one parameter-value pair, delimited by a space character. 26 | 27 | Parameters are paths from the proc(5) filesystem. Parameters paths can include 28 | glob(n) wildcards to match multiple paths. 29 | 30 | Acceptable values are determined by the parameter being set. Any parameter 31 | listed in the configuration file without a value will be excluded by 32 | clr_power(1) and the parameter will inherit the kernel's built-in default 33 | parameter value. 34 | 35 | ## EXAMPLES 36 | 37 | 1. **`clr-power-tweaks.conf`** entry to override the default value in 38 | clr_power(1) for CPU governor with **powersave**. All other values built-in 39 | to clr_power(1) would still get applied. 40 | 41 | Note the globbing used with `*` to target all CPU cores. 42 | 43 | ``` 44 | /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor powersave 45 | ``` 46 | 47 | 2. **`clr-power-tweaks.conf`** entry to exclude a parameter causing it to use 48 | the kernel's built-in default value (60). All other values built-in to 49 | clr_power(1) would still get applied. 50 | 51 | Note the omission of a value. 52 | 53 | ``` 54 | /proc/sys/vm/swappiness 55 | ``` 56 | 57 | 3. **`clr-power-tweaks.conf`** entry to add two new parameters to increase UDP 58 | buffers All other values built-in to clr_power(1) would still get applied. 59 | 60 | ``` 61 | /proc/sys/net/ipv4/udp_rmem_min 8192 62 | /proc/sys/net/ipv4/udp_wmem_min 8192 63 | ``` 64 | 65 | ## BUGS 66 | 67 | The default clr-power-tweaks.conf(5) aims to have reasonable defaults for 68 | achieving power and performance efficiency. Default values may not be optimal 69 | for all systems and environments. 70 | 71 | See GitHub Issues: 72 | 73 | ## SEE ALSO 74 | 75 | **clr_power.conf(5)**, **proc(5)**, **sysctl(2)** 76 | 77 | For parameters understood by the kernel, please see 78 | https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html -------------------------------------------------------------------------------- /man/clr_power.1: -------------------------------------------------------------------------------- 1 | .\" generated with Ronn/v0.7.3 2 | .\" http://github.com/rtomayko/ronn/tree/0.7.3 3 | . 4 | .TH "CLR_POWER" "1" "March 2020" "" "" 5 | . 6 | .SH "NAME" 7 | \fBclr_power\fR 8 | . 9 | .SH "SYNOPSIS" 10 | \fB\fBclr_power\fR\fR is a utility to adjust power and performance settings in the operating system\. It is configurable and can enforce power and performance policies\. 11 | . 12 | .P 13 | \fBclr_power\fR [\fB\-d\fR|\fB\-\-debug\fR] 14 | . 15 | .SH "DESCRIPTION" 16 | \fB\fBclr_power\fR\fR adjusts power and performance in the operating system by setting runtime kernel and device parameters in the proc(5) filesystem\. \fB\fBclr_power\fR\fR operates with built\-in default values\. Values can be added or changed in user\-defined \fBclr\-power\-tweaks\.conf(5)\fR file\. 17 | . 18 | .P 19 | \fB\fBclr_power\fR\fR applies settings and immediately exits after it is started\. It can act as a daemon that enforces settings with the included systemd files\. 20 | . 21 | .P 22 | The program handles server and desktop\-like systems differently and will set values based on whether a system is a server platform or a desktop platform\. Most systems will be assumed a server, and if it can\'t be determined what type of platform the system is, treated as a server platform\. By default, systems with CPU\'s that identify as \fBCore(TM)\fR, \fBCeleron\fR and \fBPentium\fR are treated as desktop systems, and systems with CPU\'s that identify as \fBXeon\fR are treated as server systems\. 23 | . 24 | .P 25 | Tunings applied will vary per system\. To see what tunings are applied, run the program with the \fB\-\-debug\fR option\. 26 | . 27 | .SH "OPTIONS" 28 | \fB\-d\fR, \fB\-\-debug\fR Display debug/verbose output including built\-in values\. 29 | . 30 | .P 31 | \fB\-S\fR, \fB\-\-server\fR Treat the system as a server, and apply server specific tunings\. 32 | . 33 | .P 34 | \fB\-D\fR, \fB\-\-desktop\fR Treat the system as a desktop, and apply desktop specific tunings 35 | . 36 | .SH "FILES" 37 | . 38 | .IP "\(bu" 4 39 | \fIclr\-power\.service\fR systemd service unit that executes \fBclr_power\fR\. 40 | . 41 | .IP "\(bu" 4 42 | \fIclr\-power\.timer\fR systemd timer that periodically executes the \fIclr\-power\.service\fR to enforce settings\. 43 | . 44 | .IP "\(bu" 4 45 | \fIclr\-power\-rfkill\.service\fR systemd service that stops bluetooth devices at boot to prevent power drain\. 46 | . 47 | .IP "\(bu" 4 48 | \fI/etc/clr\-power\-tweaks\.conf\fR Optional user\-defined configuration file to override or att values\. See clr\-power\-tweaks\.conf(5) for more information\. 49 | . 50 | .IP "" 0 51 | . 52 | .SH "BUGS" 53 | See GitHub Issues: \fIhttps://github\.com/clearlinux/clr\-power\-tweaks/issues\fR 54 | . 55 | .SH "SEE ALSO" 56 | \fBclr\-power\-tweaks\.conf(5)\fR, \fBproc(5)\fR 57 | -------------------------------------------------------------------------------- /man/clr_power.1.md: -------------------------------------------------------------------------------- 1 | ## SYNOPSIS 2 | 3 | **`clr_power`** is a utility to adjust power and performance settings in the 4 | operating system. It is configurable and can enforce power and performance 5 | policies. 6 | 7 | **clr_power** \[**-d**|**--debug**\] 8 | 9 | ## DESCRIPTION 10 | 11 | **`clr_power`** adjusts power and performance in the operating system by 12 | setting runtime kernel and device parameters in the proc(5) filesystem. 13 | **`clr_power`** operates with built-in default values. Values can be added or 14 | changed in user-defined **clr-power-tweaks.conf(5)** file. 15 | 16 | **`clr_power`** applies settings and immediately exits after it is started. It 17 | can act as a daemon that enforces settings with the included systemd files. 18 | 19 | The program handles server and desktop-like systems differently and 20 | will set values based on whether a system is a server platform or a 21 | desktop platform. Most systems will be assumed a server, and if it 22 | can't be determined what type of platform the system is, treated as 23 | a server platform. By default, systems with CPU's that identify as 24 | `Core(TM)`, `Celeron` and `Pentium` are treated as desktop systems, 25 | and systems with CPU's that identify as `Xeon` are treated as server 26 | systems. 27 | 28 | Tunings applied will vary per system. To see what tunings are applied, 29 | run the program with the `--debug` option. 30 | 31 | 32 | ## OPTIONS 33 | 34 | `-d`, `--debug` 35 | Display debug/verbose output including built-in values. 36 | 37 | `-S`, `--server` 38 | Treat the system as a server, and apply server specific tunings. 39 | 40 | `-D`, `--desktop` 41 | Treat the system as a desktop, and apply desktop specific tunings 42 | 43 | 44 | ## FILES 45 | 46 | - *clr-power.service* 47 | systemd service unit that executes **clr_power**. 48 | 49 | - *clr-power.timer* 50 | systemd timer that periodically executes the *clr-power.service* to enforce 51 | settings. 52 | 53 | - *clr-power-rfkill.service* 54 | systemd service that stops bluetooth devices at boot to prevent power drain. 55 | 56 | - */etc/clr-power-tweaks.conf* 57 | Optional user-defined configuration file to override or att values. See 58 | clr-power-tweaks.conf(5) for more information. 59 | 60 | 61 | ## BUGS 62 | 63 | See GitHub Issues: 64 | 65 | 66 | ## SEE ALSO 67 | 68 | **clr-power-tweaks.conf(5)**, **proc(5)** 69 | -------------------------------------------------------------------------------- /src/cpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | 36 | static void set_governor(const char *gov) 37 | { 38 | DIR *dir; 39 | struct dirent *entry; 40 | /* /sys/devices/system/cpu/cpufreq/policy0/scaling_governor */ 41 | 42 | dir = opendir("/sys/devices/system/cpu/cpufreq/"); 43 | if (!dir) 44 | return; 45 | 46 | do { 47 | char *filename; 48 | 49 | entry = readdir(dir); 50 | if (!entry) 51 | break; 52 | if (strcmp(entry->d_name, ".") == 0) 53 | continue; 54 | if (strcmp(entry->d_name, "..") == 0) 55 | continue; 56 | 57 | if (asprintf(&filename, "/sys/devices/system/cpu/cpufreq/%s/scaling_governor", entry->d_name) < 0) 58 | assert(0); 59 | 60 | write_string_to_file(filename, gov); 61 | free(filename); 62 | } while (1); 63 | 64 | closedir(dir); 65 | 66 | } 67 | 68 | 69 | void do_cpu_pm(void) 70 | { 71 | if (is_server() >= 0) { 72 | set_governor("performance"); 73 | } else { 74 | set_governor("powersave"); 75 | set_governor("schedutil"); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * This program should do all the things that are hard in udev, 5 | * that PowerTOP suggests should be changed from their kernel defaults 6 | * 7 | * Copyright (C) 2012-2018 Intel Corporation 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, version 2 or later of the License. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | * Authors: 22 | * Arjan van de Ven 23 | * 24 | */ 25 | 26 | #pragma once 27 | 28 | /* 29 | * For settings, the `where` field should normally be '0' - assume server 30 | * If you need to specify a setting for desktop only, use '-1'. 31 | * For servers, prefer '0' but use '1' if there's a desktop-alternate value. 32 | * You shouldn't have 2 entries where '0' is used as a value for `where`. 33 | */ 34 | 35 | struct write_struct { 36 | char *pathglob; 37 | char *string; 38 | int where; // -1 client, 0 neutral (assume server), 1 server only 39 | }; 40 | 41 | struct write_struct write_list[] = { 42 | // synchronous dirty ratio --> 50% 43 | {"/proc/sys/vm/dirty_ratio", "50", 0}, 44 | {"/proc/sys/kernel/unprivileged_bpf_disabled", "1", 0}, 45 | 46 | // start IO at 5% not 10%... start IO a little earlier asynchronously, since memory sizes are bigger now 47 | {"/proc/sys/vm/dirty_background_ratio", "5", 0}, 48 | 49 | // 15 seconds before the VM starts writeback, allowing the FS to deal with this better 50 | {"/proc/sys/vm/dirty_writeback_centisecs", "1500", 0}, 51 | {"/proc/sys/vm/swappiness", "10", 0}, 52 | {"/sys/kernel/mm/transparent_hugepage/khugepaged/scan_sleep_millisecs", "30000"}, 53 | {"/sys/devices/virtual/graphics/fbcon/cursor_blink", "0", 0}, 54 | {"/sys/kernel/rcu_expedited", "0", 0}, 55 | {"/proc/sys/vm/mmap_min_addr", "65536", 0}, 56 | 57 | // oom less 58 | {"/proc/sys/vm/extfrag_threshold", "100", 0}, 59 | {"/sys/kernel/mm/ksm/sleep_millisecs", "4000", 0}, 60 | 61 | // w /sys/kernel/mm/ksm/run - - - - 1 62 | {"/sys/kernel/mm/ksm/pages_to_scan", "1000", 0}, 63 | 64 | // This tuneable decides the minimum time a task will be be allowed to 65 | // run on CPU before being pre-empted out 66 | // {"/proc/sys/kernel/sched_min_granularity_ns", "2250000", 0}, 67 | // {"/proc/sys/kernel/sched_migration_cost_ns", "50000", 0}, 68 | 69 | // Ability of tasks being woken to preempt the current task 70 | // {"/proc/sys/kernel/sched_wakeup_granularity_ns", "15000000", 0}, 71 | 72 | // sched_autogroup would improve interactive desktop performance in the face of 73 | // multi‐ process, CPU-intensive workloads. Whereas it would harm performance, 74 | // thus disable it on Server 75 | {"/proc/sys/kernel/sched_autogroup_enabled", "0", 1}, 76 | 77 | // audio pm 78 | {"/sys/module/snd_hda_intel/parameters/power_save", "1", 0}, 79 | 80 | // P state stuff 81 | {"/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor", "performance", 0}, 82 | 83 | // we want at least half performance, this helps us in race-to-halt and 84 | // to give us reasonable responses 85 | {"/sys/devices/system/cpu/intel_pstate/min_perf_pct", "50", 0}, 86 | {"/proc/sys/net/core/default_qdisc", "fq", 0}, 87 | 88 | // Disable acceptance of all ICMP redirected packets on all interfaces. 89 | {"/proc/sys/net/ipv4/conf/all/accept_redirects", "0", 0}, 90 | {"/proc/sys/net/ipv6/conf/all/accept_redirects", "0", 0}, 91 | {"/proc/sys/net/ipv4/conf/default/accept_redirects", "0", 0}, 92 | {"/proc/sys/net/ipv6/conf/default/accept_redirects", "0", 0}, 93 | 94 | // Disables sending of all IPv4 ICMP redirected packets on all interfaces. 95 | {"/proc/sys/net/ipv4/conf/all/send_redirects", "0", 0}, 96 | {"/proc/sys/net/ipv4/conf/default/send_redirects", "0", 0}, 97 | 98 | // Disables acceptance of secure ICMP redirected packets on all interfaces. 99 | {"/proc/sys/net/ipv4/conf/all/secure_redirects", "0", 0}, 100 | {"/proc/sys/net/ipv4/conf/default/secure_redirects", "0", 0}, 101 | 102 | {"/proc/sys/net/ipv4/tcp_slow_start_after_idle", "0", 0}, 103 | 104 | /* breaks r8169 in 6.6 kernels 105 | {"/proc/sys/net/core/busy_poll", "50", 0}, 106 | {"/proc/sys/net/core/busy_read", "50", 0}, 107 | */ 108 | 109 | // SATA link power management 110 | {"/sys/class/scsi_host/*/link_power_management_policy", "med_power_with_dipm", 0}, 111 | 112 | // Performance tuning for SATA and NVME storage 113 | {"/sys/block/sd*/queue/scheduler", "bfq", 0}, 114 | {"/sys/block/sd*/queue/nr_requests", "4096", 0}, 115 | {"/sys/block/sd*/queue/read_ahead_kb", "1024", 0}, 116 | {"/sys/block/sd*/queue/add_random", "1", 0}, 117 | 118 | // For server, prefer mq-deadline to max throughput 119 | {"/sys/block/nvme*/queue/scheduler", "mq-deadline", 1}, 120 | 121 | // For desktop, prefer bfq low_latency 122 | {"/sys/block/nvme*/queue/scheduler", "bfq", -1}, 123 | {"/sys/block/nvme*/queue/iosched/low_latency", "0", 1}, 124 | {"/sys/block/nvme*/queue/iosched/low_latency", "1", -1}, 125 | 126 | {"/sys/block/nvme*/queue/nr_requests", "2048", 0}, 127 | {"/sys/block/nvme*/queue/read_ahead_kb", "1024", 0}, 128 | {"/sys/block/nvme*/queue/add_random", "1", 0}, 129 | 130 | // Enable turbo mode max 131 | {"/proc/sys/kernel/sched_itmt_enabled", "1", 0}, 132 | 133 | // Reload the microcode at boot 134 | {"/sys/devices/system/cpu/microcode/reload", "1", 0}, 135 | {"/sys/devices/system/cpu/cpu0/power/energy_perf_bias", "balance-performance", 0}, 136 | {"/sys/devices/system/cpu/cpu*/power/energy_perf_bias", "balance-performance", 0}, 137 | {"/sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference", "balance_performance", 0}, 138 | {"/sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference", "balance_performance", 0}, 139 | {"/sys/devices/system/cpu/cpuidle/c1_demotion", "1", 0}, 140 | 141 | 142 | {"/proc/sys/kernel/nmi_watchdog", "0", 0}, 143 | {"/sys/block/{sd,mmc,nvme, 0}*/queue/iosched/slice_idle", "0"}, 144 | 145 | // client gui interactivity 146 | {"/proc/sys/kernel/sched_autogroup_enabled", "1", -1}, 147 | 148 | // End of list. 149 | {NULL, NULL, 0} 150 | }; 151 | -------------------------------------------------------------------------------- /src/ethernet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | static void maximize_queues(char *iface) 42 | { 43 | int sock; 44 | struct ifreq ifr; 45 | int ret; 46 | struct ethtool_channels echannels; 47 | 48 | 49 | memset(&ifr, 0, sizeof(struct ifreq)); 50 | 51 | sock = socket(AF_INET, SOCK_DGRAM, 0); 52 | if (sock<0) 53 | return; 54 | 55 | strcpy(ifr.ifr_name, iface); 56 | 57 | /* Check if the interface is up */ 58 | ret = ioctl(sock, SIOCGIFFLAGS, &ifr); 59 | if (ret<0) { 60 | close(sock); 61 | return; 62 | } 63 | 64 | memset(&echannels, 0, sizeof(echannels)); 65 | 66 | echannels.cmd = ETHTOOL_GCHANNELS; 67 | ifr.ifr_data = (caddr_t)&echannels; 68 | ret = ioctl(sock, SIOCETHTOOL, &ifr); 69 | 70 | if (ret == 0 && echannels.combined_count < echannels.max_combined / 2 && echannels.max_combined > 0) { 71 | echannels.cmd = ETHTOOL_SCHANNELS; 72 | echannels.combined_count = echannels.max_combined; 73 | ioctl(sock, SIOCETHTOOL, &ifr); 74 | } 75 | close(sock); 76 | } 77 | 78 | void do_WOL(void) 79 | { 80 | DIR *dir; 81 | struct dirent *entry; 82 | 83 | dir = opendir("/sys/class/net/"); 84 | if (!dir) 85 | return; 86 | do { 87 | entry = readdir(dir); 88 | if (!entry) 89 | break; 90 | if (strcmp(entry->d_name, ".") == 0) 91 | continue; 92 | if (strcmp(entry->d_name, "..") == 0) 93 | continue; 94 | if (strcmp(entry->d_name, "lo") == 0) 95 | continue; 96 | 97 | maximize_queues(entry->d_name); 98 | 99 | } while (1); 100 | 101 | closedir(dir); 102 | } 103 | -------------------------------------------------------------------------------- /src/gfx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | 36 | 37 | void do_gfx_pm(void) 38 | { 39 | FILE *file; 40 | char line[4096]; 41 | int i; 42 | 43 | /* trigger firmware load */ 44 | file = fopen("/sys/kernel/debug/dri/0/i915_dmc_info", "r"); 45 | if (!file) 46 | return; 47 | line[0] = 0; 48 | fgets(line, 496, file); 49 | fclose(file); 50 | 51 | 52 | file = fopen("/sys/kernel/debug/dri/0/i915_max_freq", "r"); 53 | if (!file) 54 | return; 55 | line[0] = 0; 56 | fgets(line, 496, file); 57 | fclose(file); 58 | i = strtoull(line, NULL, 10); 59 | if (i == 0) 60 | return; 61 | 62 | i = i - 150; 63 | file = fopen("/sys/kernel/debug/dri/0/i915_min_freq", "w"); 64 | if (!file) 65 | return; 66 | fprintf(file, "%i\n", i); 67 | fclose(file); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/lib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2018 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | struct exclude_struct { 35 | const char *glob; 36 | struct exclude_struct *next; 37 | }; 38 | 39 | static struct exclude_struct *excludes = NULL; 40 | 41 | static bool debug_mode; 42 | 43 | /** 44 | * Initializes lib functionality. Takes one argument (dbg). If dbg is "true", 45 | * then verbose/debug output will be printed to stderr-- otherwise no output 46 | * will be printed. 47 | */ 48 | void lib_init(const bool dbg) 49 | { 50 | debug_mode = dbg; 51 | } 52 | 53 | /** 54 | * Block a glob pattern from future writes 55 | */ 56 | void string_exclude(const char *glob) 57 | { 58 | if (!excludes) { 59 | excludes = calloc(1, sizeof(struct exclude_struct)); 60 | if (!excludes) 61 | exit(EXIT_FAILURE); 62 | excludes->glob = strdup(glob); 63 | } else { 64 | struct exclude_struct *oldp = excludes; 65 | excludes = calloc(1, sizeof(struct exclude_struct)); 66 | if (!excludes) 67 | exit(EXIT_FAILURE); 68 | excludes->glob = strdup(glob); 69 | excludes->next = oldp; 70 | } 71 | } 72 | 73 | static bool is_excluded(const char *glob) 74 | { 75 | struct exclude_struct *s = excludes; 76 | while (s) { 77 | if (strcmp(s->glob, glob) == 0) 78 | return true; 79 | s = s->next; 80 | } 81 | return false; 82 | } 83 | 84 | /** 85 | * Writes @p string to file @p filename, with a newline. Returns zero 86 | * on success and -1 on failure. 87 | */ 88 | int write_string_to_file(const char *filename, const char *string) 89 | { 90 | if (is_excluded(filename)) 91 | return 0; 92 | 93 | FILE *file; 94 | file = fopen(filename, "w"); 95 | if (!file) { 96 | if (debug_mode) 97 | fprintf(stderr, "Cannot write \"%s\" to %s: %s\n", string, filename, strerror(errno)); 98 | return -1; 99 | } 100 | if (debug_mode) 101 | fprintf(stderr, "Writing \"%s\" to %s\n", string, filename); 102 | fprintf(file, "%s\n", string); 103 | fclose(file); 104 | return 0; 105 | } 106 | 107 | 108 | /** 109 | * Writes @p string to all files matched by @p match, with a 110 | * newline. Returns zero if there was a failure or non-zero on 111 | * success. All files that are matched are written to, even if a 112 | * previous one failed to. 113 | */ 114 | int write_string_to_files(const char *match, const char *string) 115 | { 116 | size_t i; 117 | glob_t globbuf; 118 | int status = 0; 119 | 120 | if (is_excluded(match)) 121 | return 0; 122 | 123 | int r = glob(match, GLOB_NOSORT | GLOB_BRACE, NULL, &globbuf); 124 | if (r == GLOB_NOMATCH) { 125 | if (debug_mode) 126 | fprintf(stderr, "No match for pattern \"%s\"\n", match); 127 | return 0; 128 | } 129 | if (r != 0) 130 | return -1; 131 | for (i = 0; i < globbuf.gl_pathc; ++i) 132 | status |= write_string_to_file(globbuf.gl_pathv[i], string); 133 | globfree(&globbuf); 134 | return status; 135 | } 136 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * This program should do all the things that are hard in udev, 5 | * that PowerTOP suggests should be changed from their kernel defaults 6 | * 7 | * Copyright (C) 2012-2018 Intel Corporation 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, version 3 of the License. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program. If not, see . 20 | * 21 | * Authors: 22 | * Arjan van de Ven 23 | * 24 | */ 25 | 26 | #define _GNU_SOURCE 27 | 28 | #include "config.h" 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #include "data.h" 42 | 43 | 44 | const char *argp_program_version = "Clear Linux Project for Intel Architecture Power Tweaks v" VERSION; 45 | 46 | const char *argp_program_bug_address = PACKAGE_BUGREPORT; 47 | 48 | const char doc[] = "Power Tweaks -- adjusts runtime kernel options for optimal power and performance"; 49 | 50 | const char args_doc[] = ""; 51 | 52 | static struct argp_option options[] = { 53 | { "debug", 'd', 0, OPTION_ARG_OPTIONAL, "Display debug/verbose output" }, 54 | { "server", 'S', 0, OPTION_ARG_OPTIONAL, "Treat system as a server platform" }, 55 | { "desktop", 'D', 0, OPTION_ARG_OPTIONAL, "Treat system as a desktop platform" }, 56 | { 0 }, 57 | }; 58 | 59 | struct arguments 60 | { 61 | char *args[1]; 62 | bool debug; 63 | int server_desktop; 64 | }; 65 | 66 | static error_t parse_opt(int key, char *arg, struct argp_state *state) 67 | { 68 | struct arguments *arguments = state->input; 69 | 70 | switch (key) { 71 | case 'd': 72 | arguments->debug = true; 73 | break; 74 | case 'S': 75 | arguments->server_desktop = 1; 76 | break; 77 | case 'D': 78 | arguments->server_desktop = -1; 79 | break; 80 | case ARGP_KEY_ARG: 81 | if (state->arg_num > 0) 82 | argp_usage(state); 83 | break; 84 | default: 85 | return ARGP_ERR_UNKNOWN; 86 | } 87 | 88 | return 0; 89 | } 90 | 91 | static struct argp argp = { options, parse_opt, args_doc, doc }; 92 | 93 | int main(int argc, char **argv) 94 | { 95 | struct arguments arguments; 96 | int status = 0; 97 | int system_is_server; 98 | 99 | arguments.debug = false; 100 | arguments.server_desktop = is_server(); 101 | 102 | argp_parse (&argp, argc, argv, 0, 0, &arguments); 103 | 104 | lib_init(arguments.debug); 105 | 106 | /* system tweaks */ 107 | for (int i = 0; write_list[i].pathglob != 0; i++) { 108 | /* 109 | * If it's a server, or we don't know, apply generic settings as well as server ones. 110 | * If it's a desktop, apply only desktop settings 111 | */ 112 | if (((arguments.server_desktop >= 0) && (write_list[i].where >= 0)) || 113 | ((arguments.server_desktop == -1) && (write_list[i].where <= 0))) { 114 | status |= write_string_to_files(write_list[i].pathglob, 115 | write_list[i].string); 116 | } 117 | } 118 | 119 | // usleep(150000); 120 | 121 | /* USB autosuspend for non-HID */ 122 | 123 | /* Runtime PM for PCI */ 124 | do_usb_pm(); 125 | 126 | /* turn off Wake-on-Lan */ 127 | do_WOL(); 128 | 129 | do_pci_pm(); 130 | do_gfx_pm(); 131 | do_cpu_pm(); 132 | verify_time(); 133 | 134 | /* user tweaks or overrides */ 135 | FILE *f = fopen("/etc/clr-power-tweaks.conf", "r"); 136 | if (f) { 137 | for (;;) { 138 | char match[PATH_MAX]; 139 | char value[PATH_MAX]; 140 | char line[PATH_MAX]; 141 | int ret; 142 | 143 | if (fgets(line, PATH_MAX, f) == NULL) 144 | break; 145 | 146 | ret = sscanf(line, "%s %s", match, value); 147 | if (ret >= 1) { 148 | /* comment */ 149 | if ((strlen(match) > 0) && (match[0] == '#')) { 150 | continue; 151 | }; 152 | }; 153 | if (ret == 1) { 154 | if (arguments.debug) 155 | fprintf(stderr, "Adding \"%s\" to exclusion list\n", match); 156 | string_exclude(match); 157 | }; 158 | if (ret == 2) { 159 | write_string_to_files(match, value); 160 | string_exclude(match); 161 | } 162 | } 163 | fclose(f); 164 | } 165 | 166 | /* do zero pages will loop and do work every 5 seconds, so it must be last */ 167 | // do_zero_pages(); 168 | return EXIT_SUCCESS; 169 | } 170 | -------------------------------------------------------------------------------- /src/mm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | 36 | 37 | void do_zero_pages(void) 38 | { 39 | FILE *file; 40 | 41 | if (nice(16)) 42 | usleep(0); 43 | while (1) { 44 | sleep(5); 45 | if (access("/proc/sys/vm/zero_pages", W_OK)) { 46 | sleep(90000); 47 | continue; 48 | } 49 | file = fopen("/proc/sys/vm/zero_pages", "w"); 50 | if (!file) 51 | continue; 52 | fprintf(file, "%i\n", 5000); 53 | fclose(file); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/pci.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include "pci-good.h" 36 | 37 | void do_pci_pm(void) 38 | { 39 | DIR *dir; 40 | struct dirent *entry; 41 | 42 | dir = opendir("/sys/bus/pci/devices/"); 43 | if (!dir) 44 | return; 45 | 46 | do { 47 | FILE *file; 48 | char *filename; 49 | char *line; 50 | size_t size; 51 | int vendor, device; 52 | int i; 53 | 54 | entry = readdir(dir); 55 | if (!entry) 56 | break; 57 | if (strcmp(entry->d_name, ".") == 0) 58 | continue; 59 | if (strcmp(entry->d_name, "..") == 0) 60 | continue; 61 | 62 | if (asprintf(&filename, "/sys/bus/pci/devices/%s/vendor", entry->d_name) < 0) 63 | assert(0); 64 | 65 | file = fopen(filename, "r"); 66 | if (!file) { 67 | free(filename); 68 | continue; 69 | } 70 | line = NULL; 71 | size = 0; 72 | if (getline(&line, &size, file) < 0) 73 | assert(0); 74 | vendor = strtoull(line, NULL, 16); 75 | free(line); 76 | free(filename); 77 | fclose(file); 78 | 79 | if (asprintf(&filename, "/sys/bus/pci/devices/%s/device", entry->d_name) < 0) 80 | assert(0); 81 | 82 | file = fopen(filename, "r"); 83 | if (!file) { 84 | free(filename); 85 | continue; 86 | } 87 | line = NULL; 88 | size = 0; 89 | if (getline(&line, &size, file) < 0) 90 | assert(0); 91 | device = strtoull(line, NULL, 16); 92 | free(line); 93 | free(filename); 94 | fclose(file); 95 | 96 | // printf("Found PCI device %04x:%04x\n", vendor, device); 97 | i = 0; 98 | while (1) { 99 | if (known_good[i].vendor == 0xffff) 100 | break; 101 | if ( (known_good[i].vendor == vendor && known_good[i].device == device)) { 102 | if (asprintf(&filename, "/sys/bus/pci/devices/%s/power/control", entry->d_name) < 0) 103 | assert(0); 104 | write_string_to_file(filename, "auto"); 105 | free(filename); 106 | break; 107 | } 108 | i++; 109 | } 110 | 111 | 112 | 113 | } while (1); 114 | 115 | closedir(dir); 116 | } 117 | -------------------------------------------------------------------------------- /src/server.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #define IS_CLIENT -1 36 | #define IS_SERVER 1 37 | #define DONTKNOW 0 38 | 39 | static char pm_profile; 40 | 41 | static void read_pm_profile(void) 42 | { 43 | FILE *file; 44 | int ret; 45 | pm_profile = ' '; 46 | file = fopen("/sys/firmware/acpi/pm_profile", "r"); 47 | if (!file) 48 | return; 49 | ret = fread(&pm_profile, 1, 1, file); 50 | if (ret) 51 | usleep(0); 52 | fclose(file); 53 | } 54 | 55 | /* see Documentation/ABI/stable/sysfs-acpi-pmprofile for the decoder info */ 56 | static int is_server_from_pm_profile(void) 57 | { 58 | if (pm_profile == '0') // 0 Unspecified 59 | return DONTKNOW; 60 | if (pm_profile == '1') // 1 Desktop 61 | return IS_CLIENT; 62 | if (pm_profile == '2') // 2 Mobile 63 | return IS_CLIENT; 64 | if (pm_profile == '3') // 3 Workstation 65 | return IS_SERVER; 66 | if (pm_profile == '4') // 4 Enterprise Server 67 | return IS_SERVER; 68 | if (pm_profile == '5') // 5 SOHO Server 69 | return IS_SERVER; 70 | if (pm_profile == '6') // 6 Appliance PC 71 | return DONTKNOW; 72 | if (pm_profile == '7') // 7 Performance Server 73 | return IS_SERVER; 74 | if (pm_profile == '8') // 8 Tablet 75 | return IS_CLIENT; 76 | 77 | return 0; 78 | } 79 | /* 80 | * returns 1 for server, -1 for client 0 for unknown 81 | */ 82 | int is_server(void) 83 | { 84 | FILE *file; 85 | int ret = 0; 86 | char buffer[8192]; 87 | 88 | read_pm_profile(); 89 | 90 | if (__builtin_cpu_is("intel") <= 0) 91 | return is_server_from_pm_profile(); 92 | 93 | file = fopen("/proc/cpuinfo", "r"); 94 | if (!file) 95 | return is_server_from_pm_profile(); 96 | while (!feof(file)) { 97 | buffer[0] = 0; 98 | char *c; 99 | c = fgets(buffer, 8191, file); 100 | if (c == NULL) 101 | break; 102 | if (strstr(buffer, "model name")) { 103 | if (strstr(buffer, "Xeon") || strstr(buffer, "Core(TM) i9")) 104 | ret = 1; 105 | else if ((strstr(buffer, "Core(TM)")) || 106 | (strstr(buffer, "Celeron")) || 107 | (strstr(buffer, "Pentium"))) 108 | ret = -1; 109 | /* 110 | * Atom - neutral for now, some Atom SoC's are client, but there are 111 | * also Atom based servers. 112 | */ 113 | } 114 | } 115 | fclose(file); 116 | if (ret == 0) 117 | ret = is_server_from_pm_profile(); 118 | return ret; 119 | } 120 | -------------------------------------------------------------------------------- /src/usb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | #include 34 | 35 | #include "usb-good.h" 36 | 37 | void do_usb_pm(void) 38 | { 39 | DIR *dir; 40 | struct dirent *entry; 41 | 42 | dir = opendir("/sys/bus/usb/devices/"); 43 | if (!dir) 44 | return; 45 | do { 46 | FILE *file; 47 | char *filename; 48 | char *line; 49 | size_t size; 50 | int vendor, device, class; 51 | int i; 52 | 53 | entry = readdir(dir); 54 | if (!entry) 55 | break; 56 | if (strcmp(entry->d_name, ".") == 0) 57 | continue; 58 | if (strcmp(entry->d_name, "..") == 0) 59 | continue; 60 | 61 | if (asprintf(&filename, "/sys/bus/usb/devices/%s/idVendor", entry->d_name) < 0) 62 | assert(0); 63 | 64 | file = fopen(filename, "r"); 65 | if (!file) { 66 | free(filename); 67 | continue; 68 | } 69 | line = NULL; 70 | size = 0; 71 | if (getline(&line, &size, file) < 0) 72 | assert(0); 73 | vendor = strtoull(line, NULL, 16); 74 | free(line); 75 | free(filename); 76 | fclose(file); 77 | 78 | if (asprintf(&filename, "/sys/bus/usb/devices/%s/idProduct", entry->d_name) < 0) 79 | assert(0); 80 | 81 | file = fopen(filename, "r"); 82 | if (!file) { 83 | free(filename); 84 | continue; 85 | } 86 | line = NULL; 87 | size = 0; 88 | if (getline(&line, &size, file) < 0) 89 | assert(0); 90 | device = strtoull(line, NULL, 16); 91 | free(line); 92 | free(filename); 93 | fclose(file); 94 | 95 | if (asprintf(&filename, "/sys/bus/usb/devices/%s/bDeviceClass", entry->d_name) < 0) 96 | assert(0); 97 | 98 | file = fopen(filename, "r"); 99 | if (!file) { 100 | free(filename); 101 | continue; 102 | } 103 | line = NULL; 104 | size = 0; 105 | if (getline(&line, &size, file) < 0) 106 | assert(0); 107 | class = strtoull(line, NULL, 16); 108 | free(line); 109 | free(filename); 110 | fclose(file); 111 | 112 | //printf("Found USB device %04x:%04x class %04x\n", vendor, device, class); 113 | i = 0; 114 | while (1) { 115 | if (known_good[i].vendor == 0xFFFF) 116 | break; 117 | if ((known_good[i].vendor == vendor && known_good[i].device == device) || 118 | (known_good[i].class == class && class != 0)) { 119 | if (asprintf(&filename, "/sys/bus/usb/devices/%s/power/control", entry->d_name) < 0) 120 | assert(0); 121 | write_string_to_file(filename, "auto"); 122 | free(filename); 123 | } 124 | 125 | i++; 126 | } 127 | 128 | 129 | 130 | } while (1); 131 | 132 | 133 | closedir(dir); 134 | } 135 | -------------------------------------------------------------------------------- /src/verifytime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Software Updater - client side 3 | * 4 | * Copyright © 2017 Intel Corporation. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Tudor Marcu 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define DAY_SECONDS 86400 31 | 32 | #define bool int 33 | #define true 1 34 | #define false 0 35 | 36 | static unsigned long int get_versionstamp(void) 37 | { 38 | FILE *fp = NULL; 39 | char data[11]; 40 | const char *filename = "/usr/share/clear/versionstamp"; 41 | unsigned long int version_num; 42 | 43 | errno = 0; 44 | fp = fopen(filename, "r"); 45 | if (fp == NULL) { 46 | if (errno == ENOENT) { 47 | fprintf(stderr, "%s does not exist!\n", filename); 48 | } else { 49 | fprintf(stderr, "Failed to open %s\n", filename); 50 | } 51 | return 0; 52 | } 53 | 54 | if (fgets(data, 11, fp) == NULL) { 55 | fprintf(stderr, "Failed to read %s\n", filename); 56 | fclose(fp); 57 | return 0; 58 | } 59 | 60 | /* If we read a 0 the versionstamp is wrong/corrupt */ 61 | errno = 0; 62 | version_num = strtoul(data, NULL, 10); 63 | if (version_num == 0 || errno != 0) { 64 | fclose(fp); 65 | return 0; 66 | } 67 | 68 | fclose(fp); 69 | return version_num; 70 | } 71 | 72 | static bool set_time(time_t mtime) 73 | { 74 | struct timespec tp; 75 | tp.tv_sec = mtime; 76 | tp.tv_nsec = 0; 77 | 78 | if (clock_settime(CLOCK_REALTIME, &tp) != 0) { 79 | fprintf(stderr, "Failed to set system time"); 80 | return false; 81 | } 82 | fprintf(stderr, "Set system time to %s\n", ctime(&mtime)); 83 | return true; 84 | } 85 | 86 | void verify_time(void) 87 | { 88 | time_t currtime; 89 | struct tm *timeinfo; 90 | unsigned long int versionstamp; 91 | 92 | time(&currtime); 93 | timeinfo = localtime(&currtime); 94 | 95 | versionstamp = get_versionstamp(); 96 | if (versionstamp == 0) { 97 | return; 98 | } 99 | time_t versiontime = (time_t)versionstamp; 100 | 101 | /* Give it a day's worth of tolerance */ 102 | if ((unsigned long int)currtime < (versionstamp - DAY_SECONDS)) { 103 | /* TODO: Get even better time than the versionstamp using a collection of servers, 104 | * and fallback to using versionstamp time if it does not work or seem reasonable. 105 | * The system time wasn't sane, so set it here and try again */ 106 | fprintf(stderr, "Warning: Current time is %s\nAttempting to fix...", asctime(timeinfo)); 107 | if (set_time(versiontime) == false) { 108 | return; 109 | } 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /template: -------------------------------------------------------------------------------- 1 | /* 2 | * Clear Linux Project for Intel Architecture Power tweaks 3 | * 4 | * Copyright (C) 2012 Intel Corporation 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, version 3 of the License. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | * 18 | * Authors: 19 | * Arjan van de Ven 20 | * 21 | */ 22 | 23 | #define _GNU_SOURCE 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | --------------------------------------------------------------------------------