static void isp_stat_try_enable(struct ispstat *stat) { unsigned long irqflags; if (stat->priv == NULL) return; spin_lock_irqsave(&stat->isp->stat_lock, irqflags); if (stat->state == ISPSTAT_ENABLING && !stat->buf_processing && stat->buf_alloc_size) { stat->update = 1; isp_stat_buf_next(stat); stat->ops->setup_regs(stat, stat->priv); isp_stat_buf_insert_magic(stat, stat->active_buf); if (!IS_H3A(stat)) atomic_set(&stat->buf_err, 0); isp_stat_pcr_enable(stat, 1); spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); dev_dbg(stat->isp->dev, "%s: module is enabled.\n", stat->subdev.name); } else { spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); } }
static void isp_stat_try_enable(struct ispstat *stat) { unsigned long irqflags; if (stat->priv == NULL) /* driver wasn't initialised */ return; spin_lock_irqsave(&stat->isp->stat_lock, irqflags); if (stat->state == ISPSTAT_ENABLING && !stat->buf_processing && stat->buf_alloc_size) { /* * Userspace's requested to enable the engine but it wasn't yet. * Let's do that now. */ stat->update = 1; isp_stat_buf_next(stat); stat->ops->setup_regs(stat, stat->priv); isp_stat_buf_insert_magic(stat, stat->active_buf); /* * H3A module has some hw issues which forces the driver to * ignore next buffers even if it was disabled in the meantime. * On the other hand, Histogram shouldn't ignore buffers anymore * if it's being enabled. */ if (!IS_H3A(stat)) atomic_set(&stat->buf_err, 0); isp_stat_pcr_enable(stat, 1); spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); dev_dbg(stat->isp->dev, "%s: module is enabled.\n", stat->subdev.name); } else { spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); } }
/* * omap3isp_stat_config - Receives new statistic engine configuration. * @new_conf: Pointer to config structure. * * Returns 0 if successful, -EINVAL if new_conf pointer is NULL, -ENOMEM if * was unable to allocate memory for the buffer, or other errors if parameters * are invalid. */ int omap3isp_stat_config(struct ispstat *stat, void *new_conf) { int ret; unsigned long irqflags; struct ispstat_generic_config *user_cfg = new_conf; u32 buf_size = user_cfg->buf_size; if (!new_conf) { dev_dbg(stat->isp->dev, "%s: configuration is NULL\n", stat->subdev.name); return -EINVAL; } mutex_lock(&stat->ioctl_lock); dev_dbg(stat->isp->dev, "%s: configuring module with buffer " "size=0x%08lx\n", stat->subdev.name, (unsigned long)buf_size); ret = stat->ops->validate_params(stat, new_conf); if (ret) { mutex_unlock(&stat->ioctl_lock); dev_dbg(stat->isp->dev, "%s: configuration values are " "invalid.\n", stat->subdev.name); return ret; } if (buf_size != user_cfg->buf_size) dev_dbg(stat->isp->dev, "%s: driver has corrected buffer size " "request to 0x%08lx\n", stat->subdev.name, (unsigned long)user_cfg->buf_size); /* * Hack: H3A modules may need a doubled buffer size to avoid access * to a invalid memory address after a SBL overflow. * The buffer size is always PAGE_ALIGNED. * Hack 2: MAGIC_SIZE is added to buf_size so a magic word can be * inserted at the end to data integrity check purpose. * Hack 3: AF module writes one paxel data more than it should, so * the buffer allocation must consider it to avoid invalid memory * access. * Hack 4: H3A need to allocate extra space for the recover state. */ if (IS_H3A(stat)) { buf_size = user_cfg->buf_size * 2 + MAGIC_SIZE; if (IS_H3A_AF(stat)) /* * Adding one extra paxel data size for each recover * buffer + 2 regular ones. */ buf_size += AF_EXTRA_DATA * (NUM_H3A_RECOVER_BUFS + 2); if (stat->recover_priv) { struct ispstat_generic_config *recover_cfg = stat->recover_priv; buf_size += recover_cfg->buf_size * NUM_H3A_RECOVER_BUFS; } buf_size = PAGE_ALIGN(buf_size); } else { /* Histogram */ buf_size = PAGE_ALIGN(user_cfg->buf_size + MAGIC_SIZE); } ret = isp_stat_bufs_alloc(stat, buf_size); if (ret) { mutex_unlock(&stat->ioctl_lock); return ret; } spin_lock_irqsave(&stat->isp->stat_lock, irqflags); stat->ops->set_params(stat, new_conf); spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); /* * Returning the right future config_counter for this setup, so * userspace can *know* when it has been applied. */ user_cfg->config_counter = stat->config_counter + stat->inc_config; /* Module has a valid configuration. */ stat->configured = 1; dev_dbg(stat->isp->dev, "%s: module has been successfully " "configured.\n", stat->subdev.name); mutex_unlock(&stat->ioctl_lock); return 0; }
int omap3isp_stat_config(struct ispstat *stat, void *new_conf) { int ret; unsigned long irqflags; struct ispstat_generic_config *user_cfg = new_conf; u32 buf_size = user_cfg->buf_size; if (!new_conf) { dev_dbg(stat->isp->dev, "%s: configuration is NULL\n", stat->subdev.name); return -EINVAL; } mutex_lock(&stat->ioctl_lock); dev_dbg(stat->isp->dev, "%s: configuring module with buffer " "size=0x%08lx\n", stat->subdev.name, (unsigned long)buf_size); ret = stat->ops->validate_params(stat, new_conf); if (ret) { mutex_unlock(&stat->ioctl_lock); dev_dbg(stat->isp->dev, "%s: configuration values are " "invalid.\n", stat->subdev.name); return ret; } if (buf_size != user_cfg->buf_size) dev_dbg(stat->isp->dev, "%s: driver has corrected buffer size " "request to 0x%08lx\n", stat->subdev.name, (unsigned long)user_cfg->buf_size); if (IS_H3A(stat)) { buf_size = user_cfg->buf_size * 2 + MAGIC_SIZE; if (IS_H3A_AF(stat)) buf_size += AF_EXTRA_DATA * (NUM_H3A_RECOVER_BUFS + 2); if (stat->recover_priv) { struct ispstat_generic_config *recover_cfg = stat->recover_priv; buf_size += recover_cfg->buf_size * NUM_H3A_RECOVER_BUFS; } buf_size = PAGE_ALIGN(buf_size); } else { buf_size = PAGE_ALIGN(user_cfg->buf_size + MAGIC_SIZE); } ret = isp_stat_bufs_alloc(stat, buf_size); if (ret) { mutex_unlock(&stat->ioctl_lock); return ret; } spin_lock_irqsave(&stat->isp->stat_lock, irqflags); stat->ops->set_params(stat, new_conf); spin_unlock_irqrestore(&stat->isp->stat_lock, irqflags); user_cfg->config_counter = stat->config_counter + stat->inc_config; stat->configured = 1; dev_dbg(stat->isp->dev, "%s: module has been successfully " "configured.\n", stat->subdev.name); mutex_unlock(&stat->ioctl_lock); return 0; }