Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] os/pm: restructure pm for LCD changes #6560

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion os/arch/arm/src/amebasmart/amebasmart_pmhelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void up_set_pm_timer(unsigned int interval_us)

void bsp_pm_domain_register(char *domain_name, int bsp_drv_id)
{
int domain_id = pm_domain_register(domain_name);
int domain_id = pm_domain_register(domain_name, PM_BACK, NULL);
if (domain_id < 0) {
pmdbg("Unable to register %s DOMAIN\n", domain_name);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static rtk_bt_evt_cb_ret_t ble_tizenrt_scatternet_gap_app_callback(uint8_t evt_c
if (!conn_ind->err) {
#ifdef CONFIG_PM
/* Register PM_BLE_DOMAIN and Perform 10 minutes timedsuspend */
domain = pm_domain_register("BLE");
domain = pm_domain_register("BLE", PM_BACK, NULL);
if (domain < 0) {
pmdbg("Unable to register BLE DOMAIN\n");
} else if (pm_timedsuspend(domain, 600000) != 0) {
Expand Down
43 changes: 16 additions & 27 deletions os/drivers/audio/ndp120_voice.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ static int ndp120_release(FAR struct audio_lowerhalf_s *dev);
static struct ndp120_dev_s *g_ndp120;
static int g_ndp120_pm_id;

static void ndp_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
static int ndp_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
static int ndp_pm_sleep(struct pm_callback_s *cb);
static void ndp_pm_wake(struct pm_callback_s *cb);

static struct pm_callback_s g_pmndpcb =
{
.notify = ndp_pm_notify,
.prepare = ndp_pm_prepare,
.sleep = ndp_pm_sleep,
.wake = ndp_pm_wake,
};
#endif

Expand Down Expand Up @@ -777,39 +777,30 @@ static void ndp120_interrupt_dispatch(int d)

#ifdef CONFIG_PM
/****************************************************************************
* Name: ndp_pm_notify
* Name: ndp_pm_sleep
*
* Description:
* Notify the driver of new power state. This callback is called after
* all drivers have had the opportunity to prepare for the new power state.
*
****************************************************************************/

static void ndp_pm_notify(struct pm_callback_s *cb, enum pm_state_e state)
static int ndp_pm_sleep(struct pm_callback_s *cb)
{
/* Currently PM follows the state changes as follows,
* On boot, we are in PM_NORMAL. After that we only use PM_STANDBY and PM_SLEEP
* on boot : PM_NORMAL -> PM_STANDBY -> PM_SLEEP, from there on
* PM_SLEEP -> PM_STANBY -> PM_SLEEP -> PM_STANBY........
* On boot, we are in PM_FORE. After that we only use PM_BACK and PM_SLEEP
* on boot : PM_FORE -> PM_BACK -> PM_SLEEP, from there on
* PM_SLEEP -> PM_BACK -> PM_SLEEP -> PM_BACK........
*/
switch (state) {
case(PM_SLEEP): {
audvdbg("entering SLEEP\n");
audvdbg("entering SLEEP\n");
#ifdef CONFIG_NDP120_AEC_SUPPORT
ndp120_aec_disable(g_ndp120);
ndp120_aec_disable(g_ndp120);
#endif
}
break;
default: {
/* Nothing to do */
audvdbg("default case\n");
}
break;
}
return OK;
}

/****************************************************************************
* Name: ndp_pm_prepare
* Name: ndp_pm_wake
*
* Description:
* Request the driver to prepare for a new power state. This is a warning
Expand All @@ -820,10 +811,9 @@ static void ndp_pm_notify(struct pm_callback_s *cb, enum pm_state_e state)
*
****************************************************************************/

static int ndp_pm_prepare(struct pm_callback_s *cb, enum pm_state_e state)
static void ndp_pm_wake(struct pm_callback_s *cb)
{
audvdbg("entry\n");
return OK;
}
#endif /* End of CONFIG_PM */

Expand Down Expand Up @@ -880,9 +870,8 @@ FAR struct audio_lowerhalf_s *ndp120_lowerhalf_initialize(FAR struct spi_dev_s *
/* only used during pm callbacks */
g_ndp120 = priv;

g_ndp120_pm_id = pm_domain_register("NDP120");
ret = pm_register(&g_pmndpcb);
DEBUGASSERT(ret == OK);
g_ndp120_pm_id = pm_domain_register("NDP120", PM_BACK, &g_pmndpcb);
DEBUGASSERT(g_ndp120_pm_id >= 0);
#endif
return &priv->dev;
}
72 changes: 31 additions & 41 deletions os/drivers/audio/syu645b.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ static void syu645b_set_equalizer(FAR struct syu645b_dev_s *priv, uint32_t prese

#ifdef CONFIG_PM
static struct syu645b_dev_s *g_syu645b;
static void syu645b_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
static int syu645b_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
static void syu645b_pm_sleep(struct pm_callback_s *cb);
static int syu645b_pm_wake(struct pm_callback_s *cb);
static struct pm_callback_s g_pm_syu645b_cb ={
.notify = syu645b_pm_notify,
.prepare = syu645b_pm_prepare,
.sleep = syu645b_pm_sleep,
.wake = syu645b_pm_wake,
};
static int syu645b_pm_domain_id = -1;
#endif

/************************************************************************************
Expand Down Expand Up @@ -786,7 +787,7 @@ static int syu645b_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct a
timeout = (CONFIG_SYU645B_BUFFER_SIZE * CONFIG_SYU645B_NUM_BUFFERS * BYTE_TO_BIT_FACTOR * SEC_TO_MSEC_FACTOR) / (priv->samprate * priv->nchannels * priv->bpsamp) + I2S_TIMEOUT_OFFSET_MS;

#ifdef CONFIG_PM
pm_timedsuspend(pm_domain_register("AUDIO"), timeout);
pm_timedsuspend(syu645b_pm_domain_id, timeout);
#endif
ret = I2S_SEND(priv->i2s, apb, syu645b_txcallback, priv, timeout);

Expand Down Expand Up @@ -1052,57 +1053,40 @@ static void syu645b_set_equalizer(FAR struct syu645b_dev_s *priv, uint32_t prese

#ifdef CONFIG_PM
/****************************************************************************
* Name: syu645b_pm_notify
* Name: syu645b_pm_sleep
*
* Description:
* Notify the driver of new power state. This callback is called after
* all drivers have had the opportunity to prepare for the new power state.
*
****************************************************************************/

static void syu645b_pm_notify(struct pm_callback_s *cb, enum pm_state_e state)
static int syu645b_pm_sleep(struct pm_callback_s *cb)
{
/* Currently PM follows the state changes as follows,
* On boot, we are in PM_NORMAL. After that we only use PM_STANDBY and PM_SLEEP
* on boot : PM_NORMAL -> PM_STANDBY -> PM_SLEEP, from there on
* PM_SLEEP -> PM_STANBY -> PM_SLEEP -> PM_STANBY........
* On boot, we are in PM_FORE. After that we only use PM_BACK and PM_SLEEP
* on boot : PM_FORE -> PM_BACK -> PM_SLEEP, from there on
* PM_SLEEP -> PM_BACK -> PM_SLEEP -> PM_BACK........
*/
audvdbg("pmstate : %d\n", state);
#if 0
struct syu645b_lower_s *lower = g_syu645b->lower;
#endif
switch (state) {
case(PM_SLEEP): {
#if 0
if (lower->control_hw_reset) {
lower->control_hw_reset(true);
up_mdelay(100);
lower->control_hw_reset(false);
up_mdelay(100);
}
#endif
/* To prevent consume 12v, just mute on */
syu645b_setmute(g_syu645b, true);
if (lower->control_hw_reset) {
lower->control_hw_reset(true);
up_mdelay(100);
lower->control_hw_reset(false);
up_mdelay(100);
}
break;
case(PM_STANDBY): {
#if 0
syu645b_reset_config(g_syu645b);
#endif
/* Mute off when wake up */
syu645b_setmute(g_syu645b, false);
}
break;
default: {
/* Nothing to do */
audvdbg("default case\n");
}
break;
}
/* To prevent consume 12v, just mute on */
syu645b_setmute(g_syu645b, true);
return OK;
}

/****************************************************************************
* Name: syu645b_pm_prepare
* Name: syu645b_pm_wake
*
* Description:
* Request the driver to prepare for a new power state. This is a warning
Expand All @@ -1113,10 +1097,16 @@ static void syu645b_pm_notify(struct pm_callback_s *cb, enum pm_state_e state)
*
****************************************************************************/

static int syu645b_pm_prepare(struct pm_callback_s *cb, enum pm_state_e state)
static void syu645b_pm_wake(struct pm_callback_s *cb)
{
audvdbg("pmstate : %d\n", state);
return OK;
#if 0
struct syu645b_lower_s *lower = g_syu645b->lower;
#endif
#if 0
syu645b_reset_config(g_syu645b);
#endif
/* Mute off when wake up */
syu645b_setmute(g_syu645b, false);
}
#endif /* End of CONFIG_PM */

Expand Down Expand Up @@ -1181,8 +1171,8 @@ FAR struct audio_lowerhalf_s *syu645b_initialize(FAR struct i2c_dev_s *i2c, FAR
/* only used during pm callbacks */
g_syu645b = priv;

int ret = pm_register(&g_pm_syu645b_cb);
DEBUGASSERT(ret == OK);
syu645b_pm_domain_id = pm_domain_register("AUDIO", PM_FORE, &g_pm_syu645b_cb);
DEBUGASSERT(syu645b_pm_domain_id >= 0);
#endif

return &priv->dev;
Expand Down
2 changes: 1 addition & 1 deletion os/drivers/lcd/lcd_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ int lcddev_register(struct lcd_dev_s *dev)
#endif

#ifdef CONFIG_PM
lcd_info->pm_domain = pm_domain_register("LCD");
lcd_info->pm_domain = pm_domain_register("LCD", PM_FORE, NULL);
#endif

lcd_init_put_image(dev);
Expand Down
2 changes: 1 addition & 1 deletion os/drivers/pm/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int pm_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
ret = -EINVAL;
pmdbg("Please input correct arguments\n");
} else {
((pm_domain_arg_t *)arg)->domain_id = pm_domain_register(((pm_domain_arg_t *)arg)->domain_name);
((pm_domain_arg_t *)arg)->domain_id = pm_domain_register(((pm_domain_arg_t *)arg)->domain_name, PM_BACK, NULL);
if (((pm_domain_arg_t *)arg)->domain_id >= 0) {
ret = OK;
}
Expand Down
2 changes: 1 addition & 1 deletion os/drivers/serial/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ static int uart_open(FAR struct file *filep)
#ifdef CONFIG_PM
/* Register PM_UART_DOMAIN to access PM APIs during UART operations. */
if (pm_uart_domain_id == -1) {
ret = pm_domain_register(PM_UART_DOMAIN);
ret = pm_domain_register(PM_UART_DOMAIN, PM_BACK, NULL);
if (ret < 0) {
return ret;
}
Expand Down
Loading