View Single Post
Old 04-16-2022, 06:34 PM   #771
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
Never have I said that this wasn't an NTX quirk, but the fact is that the kernel begs to differ:

Code:
static void _ntx_wifi_bt_power_ctrl (int power_status)
{
	int bus;
	int iOldStatus;

	iOldStatus = gi_wifi_power_status;

	//if (14 == gptHWCFG->m_val.bCPU)	// B300
	{
		printk("Wifi / BT power control %d\n", power_status);

		if (power_status & 0x3)	{
			printk("wifi/BT power on\n");
			sunxi_wlan_set_power(1);
		} 

		/* Bluetooth power control */
		if (0 != gptHWCFG->m_val.bBT) {
			if ((power_status & 0x2) == (iOldStatus & 0x2)) {  /* Bluetooth dis status */
				printk("Bluetooth already %s.\n",(power_status & 0x2)?"on":"off");
			} else if (power_status & 0x2) {
				printk("Bluetooth On\n");
				sunxi_bluetooth_set_power(1);
				gi_wifi_power_status |= 2;
			} else {
				printk("Bluetooth Off\n");
				gi_wifi_power_status &= ~2;
			}
		}

		/* Wifi power control */
		printk(KERN_ERR"[DEBUG] power_status:%d , iOldStatus:%d \n",power_status,iOldStatus);
		if ((power_status & 0x1) == (iOldStatus & 0x1)) {  /* check Wifi status */
			printk ("Wifi already %s.\n",(power_status & 0x1)?"on":"off");
		} else if (power_status & 0x1) {
			printk("Wifi On\n");
			//gpiod_direction_output(GPIO_WIFI_RST, 1);
			gi_wifi_power_status |= 1;
		} else {
			printk("Wifi Off\n");
			gi_wifi_power_status &= ~1;
		}

		//printk("Wifi/BT bus:%d \n",bus);
		bus = sunxi_wlan_get_bus_index() ;
		if( power_status&0x3 ) {
			if ( (!!power_status) != (!!iOldStatus) ) {
				sunxi_wlan_set_dis(1);	 /* Wifi dis pull high */
				//printk("sunxi_mmc_rescan_card !!\n");
				msleep(300);
				printk(KERN_DEBUG" sunxi_mmc_rescan_card bus%d!!\n",bus);
				sunxi_mmc_rescan_card(bus);
				msleep(300);
			}
		}
		else if ( 0==power_status ) {
			if ( power_status != iOldStatus )
			{
				sunxi_wlan_set_dis(0);	/* Wifi dis pull low */
				printk(KERN_DEBUG" remove card bus%d!!\n",bus);
				sunxi_mmc_set_card_removed(bus);
				msleep(300);
			}
		}

	
		if (0 != gptHWCFG->m_val.bBT) {
			if ( !(power_status&2) )	{
				sunxi_bluetooth_set_power(0);
				//printk("bt off\n");
			}
		}

		if(0==power_status) {
			printk("wifi/bt device power off\n");
			sunxi_wlan_set_power(0);
			sunxi_mmc_set_card_removed(bus);
			msleep(300);
		}

	}
	//printk("%s() : done \n",__FUNCTION__);
}
That's the ioctl handler.

Keep in mind that I want to make the distinction between powering (hw/sw) and enabling (ui) and connecting (hw/sw/ui) very clear, as the three could theoretically be distinct.

Last edited by NiLuJe; 04-16-2022 at 06:39 PM.
NiLuJe is offline   Reply With Quote