This is totally fucked up code, but if you like hazard...
I mean that I really just called some random ACPI (aml) methods
not knowing what they should do.
Additionally this code is for my laptop. I have GEFORCE 620M
GPU, so I added this to pcidevs. Another thing is that patched
code recognizes my GPU device through ACPI name
"\\_SB_.PCI0.PEG0.PEGP". I have discovered name when I was
using Linux kernel's module called acpi_call. Other laptops
may have differently named GPUs.
You use this at your own risk and you must *not* report bugs
to Project when using patched kernel.
File: GENERIC Status: Locally Modified
Working revision: 1.427
Repository revision: 1.427 /cvs/src/sys/arch/amd64/conf/GENERIC,v
Commit Identifier: xNzAQvg5oqM2b0pn
File: acpi.c Status: Locally Modified
Working revision: 1.313
Repository revision: 1.313 /cvs/src/sys/dev/acpi/acpi.c,v
Commit Identifier: h0GHFDGWnEdswfbK
File: dsdt.c Status: Locally Modified
Working revision: 1.223
Repository revision: 1.223 /cvs/src/sys/dev/acpi/dsdt.c,v
Commit Identifier: SBTJg3diM8lXHXRE
File: files.pci Status: Locally Modified
Working revision: 1.324
Repository revision: 1.324 /cvs/src/sys/dev/pci/files.pci,v
Commit Identifier: aeD3LK9Qomrjecge
File: pcidevs Status: Locally Modified
Working revision: 1.1802
Repository revision: 1.1802 /cvs/src/sys/dev/pci/pcidevs,v
Commit Identifier: ZupaPoe9OBu6iKll
File: pcidevs.h Status: Locally Modified
Working revision: 1.1796
Repository revision: 1.1796 /cvs/src/sys/dev/pci/pcidevs.h,v
Commit Identifier: Z3aUcOQiFLoINK6d
File: pcidevs_data.h Status: Locally Modified
Working revision: 1.1791
Repository revision: 1.1791 /cvs/src/sys/dev/pci/pcidevs_data.h,v
Commit Identifier: Z3aUcOQiFLoINK6d
Index: sys/arch/amd64/conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/GENERIC,v
retrieving revision 1.427
diff -u -p -r1.427 GENERIC
--- sys/arch/amd64/conf/GENERIC 3 Aug 2016 17:23:38 -0000 1.427
+++ sys/arch/amd64/conf/GENERIC 19 Aug 2016 21:31:07 -0000
@@ -11,7 +11,7 @@
machine amd64
include "../../../conf/GENERIC"
-maxusers 80 # estimated number of users
+maxusers 100 # estimated number of users
option USER_PCICONF # user-space PCI configuration
@@ -22,10 +22,14 @@ option MTRR # CPU memory range
attribu
#option KGDB # Remote debugger support; exclusive of
DDB
#option "KGDB_DEVNAME=\"com\"",KGDBADDR=0x2f8,KGDBRATE=9600
-option NTFS # NTFS support
+#option NTFS # NTFS support
option HIBERNATE # Hibernate support
+
+option HZ=300
+
config bsd swap generic
+#option DEBUG
mainbus0 at root
@@ -399,6 +403,7 @@ adw* at pci? # AdvanSys
ULTRA WIDE SC
pcscp* at pci? # AMD 53c974 PCscsi-PCI SCSI
#trm* at pci? # Tekram DC-3x5U SCSI Controllers
vmwpvs* at pci? # VMware ParaVirtual SCSI
+nvdsbl* at pci? # Nvidia PCI Driver for disabling
nvme* at pci? # NVMe controllers
scsibus* at scsi?
Index: sys/dev/acpi/acpi.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpi.c,v
retrieving revision 1.313
diff -u -p -r1.313 acpi.c
--- sys/dev/acpi/acpi.c 28 Jul 2016 21:57:56 -0000 1.313
+++ sys/dev/acpi/acpi.c 19 Aug 2016 21:31:44 -0000
@@ -562,11 +562,11 @@ acpi_getpci(struct aml_node *node, void
{
const char *pcihid[] = { ACPI_DEV_PCIB, ACPI_DEV_PCIEB, "HWP0002", 0 };
struct acpi_pci *pci, *ppci;
- struct aml_value res;
+ struct aml_value res,res2;
struct acpi_softc *sc = arg;
pci_chipset_tag_t pc = NULL;
pcitag_t tag;
- uint64_t val;
+ uint64_t val,val2;
uint32_t reg;
if (!node->value || node->value->type != AML_OBJTYPE_DEVICE)
@@ -620,6 +620,35 @@ acpi_getpci(struct aml_node *node, void
pci->bus, pci->dev, pci->fun,
aml_nodename(node));
+
+ bool czyNvidiaGPU = false;
+ if (!(strcmp("\\_SB_.PCI0.PEG0.PEGP",aml_nodename(node))))
+ czyNvidiaGPU = true;
+
+ if (czyNvidiaGPU) {
+ printf("bedzie evalname na GPU\n");
+ bool czyPoprawnieName = false;
+ if(aml_evalname(sc, node, "_OFF", 0, NULL, &res2)){
+ printf("evalname na GPU true\n");
+ czyPoprawnieName = true;
+ aml_freevalue(&res2);
+ } else {
+ printf("evalname na GPU false\n");
+ czyPoprawnieName = false;
+ }
+
+ if (res2.type == AML_OBJTYPE_PACKAGE) printf("zwrocono
AML_OBJTYPE_PACKAGE\n");
+
+ if (!czyPoprawnieName) {
+ if(aml_evalinteger(sc, node, "_OFF", 0, NULL, &val2)){
+ printf("evalint wykonano i true\n");
+ } else {
+ printf("evalint wykonano i false\n");
+ }
+ }
+
+ }
+
/* Collect device power state information. */
if (aml_evalinteger(sc, node, "_S3D", 0, NULL, &val) == 0)
pci->_s3d = val;
@@ -675,7 +704,8 @@ void
acpi_pci_match(struct device *dev, struct pci_attach_args *pa)
{
struct acpi_pci *pdev;
- int state;
+ int state,minstate;
+ pcitag_t tag;
TAILQ_FOREACH(pdev, &acpi_pcidevs, next) {
if (pdev->bus != pa->pa_bus ||
@@ -693,9 +723,30 @@ acpi_pci_match(struct device *dev, struc
* initialize them.
*/
state = pci_get_powerstate(pa->pa_pc, pa->pa_tag);
- acpi_pci_set_powerstate(pa->pa_pc, pa->pa_tag, state, 1);
- acpi_pci_set_powerstate(pa->pa_pc, pa->pa_tag, state, 0);
-
+ tag = pci_make_tag(pa->pa_pc, pdev->bus, pdev->dev, pdev->fun);
+ minstate = acpi_pci_min_powerstate(pa->pa_pc, tag);
+ bool czyGPU2 = false;
+ czyGPU2 =
!(strcmp("\\_SB_.PCI0.PEG0.PEGP",aml_nodename(pdev->node)));
+ if (czyGPU2){
+ printf("Zmieniam stan zasilania z %d na
%d\n",state,PCI_PMCSR_STATE_D3);
+ printf("Minimalny stan zasilania %d\n",minstate);
+ state=PCI_PMCSR_STATE_D3;
+ acpi_pci_set_powerstate(pa->pa_pc, tag, state, 1);
+ acpi_pci_set_powerstate(pa->pa_pc, tag, state, 0);
+ pci_set_powerstate(pa->pa_pc, tag, PCI_PMCSR_STATE_D3);
+ } else {
+
+
+ acpi_pci_set_powerstate(pa->pa_pc, pa->pa_tag, state, 1);
+ acpi_pci_set_powerstate(pa->pa_pc, pa->pa_tag, state, 0);
+
+ }
+
+ if(czyGPU2){
+ state=128;
+ state = pci_get_powerstate(pa->pa_pc, tag);
+ printf("Zasilanie zmieniono na stan %d\n",state);
+ }
aml_register_notify(pdev->node, NULL, acpi_pci_notify, pdev, 0);
}
}
Index: sys/dev/pci/files.pci
===================================================================
RCS file: /cvs/src/sys/dev/pci/files.pci,v
retrieving revision 1.324
diff -u -p -r1.324 files.pci
--- sys/dev/pci/files.pci 17 Mar 2016 04:02:00 -0000 1.324
+++ sys/dev/pci/files.pci 19 Aug 2016 21:33:18 -0000
@@ -121,6 +121,11 @@ device eso {}: audio, midibus
attach eso at pci
file dev/pci/eso.c eso
+#Acer Optimus nvdsbl disable nvidia gpu PCI
+device nvdsbl
+attach nvdsbl at pci
+file dev/pci/nvdsbl.c
+
# Acer Labs M5455
device auacer: audio, ac97
attach auacer at pci
Index: sys/dev/pci/pcidevs
===================================================================
RCS file: /cvs/src/sys/dev/pci/pcidevs,v
retrieving revision 1.1802
diff -u -p -r1.1802 pcidevs
--- sys/dev/pci/pcidevs 31 Jul 2016 07:36:16 -0000 1.1802
+++ sys/dev/pci/pcidevs 19 Aug 2016 21:34:00 -0000
@@ -6107,6 +6107,7 @@ product NVIDIA MCP89_OHCI 0x0d9c MCP89 U
product NVIDIA MCP89_EHCI 0x0d9d MCP89 USB
product NVIDIA GEFORCEGTX460M 0x0dd1 GeForce GTX 460M
product NVIDIA GEFORCE_425M 0x0df0 GeForce 425M
+product NVIDIA GEFORCE_620M 0x1140 Geforce 620M
product NVIDIA GEFORCEGTX550TI 0x1244 GeForce GTX 550 Ti
product NVIDIA GEFORCEGTS450_1 0x1245 GeForce GTS 450
product NVIDIA GEFORCEGT550M 0x1246 GeForce GT 550M
After that go to cd sys/dev/pci/ and execute:
# make
You use this at your own risk and you mustn't report bugs
to Project when using patched kernel.