static void drm_mixer_qos_ctrl(struct device *dev) { struct drm_hdmi_context *ctx = to_context(dev); int win, val, count = 0; DRM_DEBUG_KMS("%s\n", __func__); for (win = 0; win < MIXER_WIN_NR; win++) if (ctx->enabled[win]) count++; switch (count) { case 1: val = 160160; break; case 2 ... MIXER_WIN_NR: val = 267160; break; default: val = 0; break; } DRM_DEBUG_KMS("%s:count[%d]val[%d]\n", __func__, count, val); #if defined(CONFIG_BUSFREQ_OPP) || defined(CONFIG_BUSFREQ_LOCK_WRAPPER) if (val == 0) dev_unlock(ctx->bus_dev, dev); else dev_lock(ctx->bus_dev, dev, val); #endif }
static void ctty_clone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev) { if (*dev != NULL) return; if (strcmp(name, "tty")) return; sx_sunlock(&clone_drain_lock); sx_slock(&proctree_lock); sx_slock(&clone_drain_lock); dev_lock(); if (!(curthread->td_proc->p_flag & P_CONTROLT)) *dev = ctty; else if (curthread->td_proc->p_session->s_ttyvp == NULL) *dev = ctty; else if (curthread->td_proc->p_session->s_ttyvp->v_type == VBAD || curthread->td_proc->p_session->s_ttyvp->v_rdev == NULL) { /* e.g. s_ttyvp was revoked */ *dev = ctty; } else *dev = curthread->td_proc->p_session->s_ttyvp->v_rdev; dev_refl(*dev); dev_unlock(); sx_sunlock(&proctree_lock); }
static void busfreq_late_resume(struct early_suspend *h) { struct busfreq_data *data = container_of(h, struct busfreq_data, busfreq_early_suspend_handler); /* Request min MIF/INT 300MHz */ dev_lock(data->dev[PPMU_MIF], data->dev[PPMU_MIF], 300150); }
int s3cfb_enable_window(struct s3cfb_global *fbdev, int id) { struct s3cfb_window *win = fbdev->fb[id]->par; #ifdef FEATURE_BUSFREQ_LOCK int enabled_win = 0; #endif #if defined(CONFIG_CPU_EXYNOS4212) || defined(CONFIG_CPU_EXYNOS4412) #ifdef CONFIG_BUSFREQ_OPP if (id != CONFIG_FB_S5P_DEFAULT_WINDOW) dev_lock(fbdev->bus_dev, fbdev->dev, 133133); #endif #endif if (!win->enabled) atomic_inc(&fbdev->enabled_win); #ifdef FEATURE_BUSFREQ_LOCK enabled_win = atomic_read(&fbdev->enabled_win); if (enabled_win >= 2) s3cfb_busfreq_lock(fbdev, 1); #endif if (s3cfb_window_on(fbdev, id)) { win->enabled = 0; return -EFAULT; } else { win->enabled = 1; return 0; } }
static int gp_port_usbdiskdirect_lock (GPPort *port, const char *path) { #ifdef HAVE_LOCKDEV int pid; GP_LOG_D ("Trying to lock '%s'...", path); pid = dev_lock (path); if (pid) { if (port) { if (pid > 0) gp_port_set_error (port, _("Device '%s' is " "locked by pid %d"), path, pid); else gp_port_set_error (port, _("Device '%s' could " "not be locked (dev_lock returned " "%d)"), path, pid); } return GP_ERROR_IO_LOCK; } #else # ifdef __GCC__ # warning No locking library found. # warning You will run into problems if you use # warning gphoto2 with a usbdiskdirect picframe in # warning combination with Konqueror (KDE) or Nautilus (GNOME). # warning This will *not* concern USB cameras. # endif #endif return GP_OK; }
static int jpeg_m2m_open(struct file *file) { struct jpeg_dev *dev = video_drvdata(file); struct jpeg_ctx *ctx = NULL; int ret = 0; enum jpeg_node_type node; node = jpeg_get_node_type(file); if (node == JPEG_NODE_INVALID) { jpeg_err("cannot specify node type\n"); ret = -ENOENT; goto err_node_type; } ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; file->private_data = ctx; ctx->dev = dev; spin_lock_init(&ctx->slock); if (node == JPEG_NODE_DECODER) ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_dec, ctx, queue_init_dec); else ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev_enc, ctx, queue_init_enc); if (IS_ERR(ctx->m2m_ctx)) { int err = PTR_ERR(ctx->m2m_ctx); kfree(ctx); return err; } clk_enable(dev->clk); #ifdef CONFIG_PM_RUNTIME #if defined (CONFIG_CPU_EXYNOS5250) dev->vb2->resume(dev->alloc_ctx); #ifdef CONFIG_BUSFREQ_OPP /* lock bus frequency */ dev_lock(dev->bus_dev, &dev->plat_dev->dev, BUSFREQ_400MHZ); #endif #else pm_runtime_get_sync(&dev->plat_dev->dev); #endif #endif return 0; err_node_type: kfree(ctx); return ret; }
static int exynos_frequency_lock(struct device *dev) { unsigned int level, cpufreq = 600; /* 200 ~ 1400 */ unsigned int busfreq = 400200; /* 100100 ~ 400200 */ int ret = 0, lock_id; atomic_t *freqlock; struct device *busdev = dev_get("exynos-busfreq"); if (!strcmp(dev->bus->name, "usb")) { lock_id = DVFS_LOCK_ID_USB_IF; cpufreq = 600; freqlock = &umts_link_pm_data.freqlock; } else if (!strcmp(dev->bus->name, "platform")) { // for dpram lock lock_id = DVFS_LOCK_ID_DPRAM_IF; cpufreq = 800; freqlock = &umts_link_pm_data.freq_dpramlock; } else { mif_err("ERR: Unkown unlock ID (%s)\n", dev->bus->name); goto exit; } if (atomic_read(freqlock) == 0) { /* cpu frequency lock */ ret = exynos_cpufreq_get_level(cpufreq * 1000, &level); if (ret < 0) { mif_err("ERR: exynos_cpufreq_get_level fail: %d\n", ret); goto exit; } ret = exynos_cpufreq_lock(lock_id, level); if (ret < 0) { mif_err("ERR: exynos_cpufreq_lock fail: %d\n", ret); goto exit; } /* bus frequncy lock */ if (!busdev) { mif_err("ERR: busdev is not exist\n"); ret = -ENODEV; goto exit; } ret = dev_lock(busdev, dev, busfreq); if (ret < 0) { mif_err("ERR: dev_lock error: %d\n", ret); goto exit; } /* lock minimum number of cpu cores */ cpufreq_pegasusq_min_cpu_lock(2); atomic_set(freqlock, 1); mif_info("level=%d, cpufreq=%d MHz, busfreq=%06d\n", level, cpufreq, busfreq); } exit: return ret; }
static void busfreq_early_suspend(struct early_suspend *h) { unsigned long freq; struct busfreq_data *data = container_of(h, struct busfreq_data, busfreq_early_suspend_handler); freq = data->min_freq[PPMU_MIF] + data->min_freq[PPMU_INT] / 1000; dev_lock(data->dev[PPMU_MIF], data->dev[PPMU_MIF], freq); }
/** * exynos_tc_volt - locks or frees vdd_arm, vdd_mif/int and vdd_g3d for * temperature compensation. * * This function limits or free voltage of cpufreq, busfreq, and mali driver * according to 2nd arguments. */ static int exynos_tc_volt(struct s5p_tmu_info *info, int enable) { struct s5p_platform_tmu *data; static int usage; int ret = 0; if (!info || !(info->dev)) return -EPERM; data = info->dev->platform_data; if (enable == usage) { pr_debug("TMU: already is %s.\n", enable ? "locked" : "unlocked"); return 0; } if (enable) { ret = exynos_cpufreq_lock(DVFS_LOCK_ID_TMU, info->cpulevel_tc); if (ret) goto err_lock; #ifdef CONFIG_BUSFREQ_OPP ret = dev_lock(info->bus_dev, info->dev, info->busfreq_tc); if (ret) goto err_lock; #endif #if defined(CONFIG_VIDEO_MALI400MP) ret = mali_voltage_lock_push(data->temp_compensate.g3d_volt); if (ret < 0) { pr_err("TMU: g3d_push error: %u uV\n", data->temp_compensate.g3d_volt); goto err_lock; } #endif } else { exynos_cpufreq_lock_free(DVFS_LOCK_ID_TMU); #ifdef CONFIG_BUSFREQ_OPP ret = dev_unlock(info->bus_dev, info->dev); if (ret) goto err_unlock; #endif #if defined(CONFIG_VIDEO_MALI400MP) ret = mali_voltage_lock_pop(); if (ret < 0) { pr_err("TMU: g3d_pop error\n"); goto err_unlock; } #endif } usage = enable; pr_info("TMU: %s is ok!\n", enable ? "lock" : "unlock"); return ret; err_lock: err_unlock: pr_err("TMU: %s is fail.\n", enable ? "lock" : "unlock"); return ret; }
void dev_relthread(struct cdev *dev) { mtx_assert(&devmtx, MA_NOTOWNED); dev_lock(); KASSERT(dev->si_threadcount > 0, ("%s threadcount is wrong", dev->si_name)); dev->si_threadcount--; dev_unlock(); }
static int jpeg_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct jpeg_dev *jpeg_drv = platform_get_drvdata(pdev); #ifdef CONFIG_BUSFREQ_OPP /* lock bus frequency */ dev_lock(jpeg_drv->bus_dev, &jpeg_drv->plat_dev->dev, BUSFREQ_400MHZ); #endif clk_enable(jpeg_drv->clk); jpeg_drv->vb2->resume(jpeg_drv->alloc_ctx); return 0; }
int s3cfb_extdsp_enable_window(struct s3cfb_extdsp_global *fbdev, int id) { struct s3cfb_extdsp_window *win = fbdev->fb[id]->par; #ifdef CONFIG_BUSFREQ_OPP dev_lock(fbdev->bus_dev, fbdev->dev, 133133); #endif if (!win->enabled) atomic_inc(&fbdev->enabled_win); win->enabled = 1; return 0; }
void free_dvfs_lock(struct work_struct *work) { struct wacom_i2c *wac_i2c = container_of(work, struct wacom_i2c, dvfs_work.work); if (wac_i2c->dvfs_lock_status) dev_lock(wac_i2c->bus_dev, wac_i2c->dev, SEC_BUS_LOCK_FREQ); else { dev_unlock(wac_i2c->bus_dev, wac_i2c->dev); exynos_cpufreq_lock_free(DVFS_LOCK_ID_PEN); } }
static int fimc_is_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct v4l2_subdev *sd = platform_get_drvdata(pdev); struct fimc_is_dev *is_dev = to_fimc_is_dev(sd); printk(KERN_INFO "FIMC-IS runtime resume\n"); #ifdef CONFIG_REGULATOR regulator_enable(is_dev->r_vdd18_cam); regulator_enable(is_dev->r_vddio18_cam); regulator_enable(is_dev->r_vdd28_af_cam); regulator_enable(is_dev->r_vadd28_cam); #endif if (is_dev->pdata->clk_cfg) { is_dev->pdata->clk_cfg(pdev); } else { printk(KERN_ERR "#### failed to Clock CONFIG ####\n"); return -EINVAL; } if (is_dev->pdata->clk_on) { is_dev->pdata->clk_on(pdev); } else { printk(KERN_ERR "#### failed to Clock On ####\n"); return -EINVAL; } is_dev->frame_count = 0; #if defined(CONFIG_VIDEOBUF2_ION) if (is_dev->alloc_ctx) fimc_is_mem_resume(is_dev->alloc_ctx); #endif #if defined(CONFIG_BUSFREQ_OPP) || defined(CONFIG_BUSFREQ_LOCK_WRAPPER) /* lock bus frequency */ dev_lock(is_dev->bus_dev, dev, BUS_LOCK_FREQ_L0); pm_qos_add_request(&bus_qos_pm_qos_req, PM_QOS_BUS_QOS, 1); #endif #ifdef CONFIG_EXYNOS4_CPUFREQ if (exynos_cpufreq_lock(DVFS_LOCK_ID_CAM, L8)) { printk(KERN_ERR "ISP: failed to cpufreq lock for L0"); } #endif mutex_lock(&is_dev->lock); clear_bit(IS_PWR_ST_POWEROFF, &is_dev->power); clear_bit(IS_PWR_SUB_IP_POWER_OFF, &is_dev->power); set_bit(IS_PWR_ST_POWERON, &is_dev->power); mutex_unlock(&is_dev->lock); printk(KERN_INFO "FIMC-IS runtime resume end\n"); return 0; }
static int jpeg_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct jpeg_dev *jpeg_drv = platform_get_drvdata(pdev); #if defined(CONFIG_MACH_P11) || defined(CONFIG_MACH_P10) return 0; #endif #ifdef CONFIG_BUSFREQ_OPP /* lock bus frequency */ dev_lock(jpeg_drv->bus_dev, dev, BUSFREQ_400MHZ); #endif jpeg_drv->vb2->resume(jpeg_drv->alloc_ctx); return 0; }
static int gp_port_serial_lock (GPPort *dev, const char *path) { #if defined(HAVE_LOCKDEV) int pid; #endif gp_log (GP_LOG_DEBUG, "gphoto2-port-serial", "Trying to lock '%s'...", path); #if defined(HAVE_TTYLOCK) if (ttylock ((char*) path)) { if (dev) gp_port_set_error (dev, _("Could not lock device " "'%s'"), path); return (GP_ERROR_IO_LOCK); } #define __HAVE_LOCKING #elif defined(HAVE_LOCKDEV) pid = dev_lock (path); if (pid) { if (dev) { if (pid > 0) gp_port_set_error (dev, _("Device '%s' is " "locked by pid %d"), path, pid); else gp_port_set_error (dev, _("Device '%s' could " "not be locked (dev_lock returned " "%d)"), path, pid); } return (GP_ERROR_IO_LOCK); } #define __HAVE_LOCKING #endif #ifndef __HAVE_LOCKING # ifdef __GCC__ # warning No locking library found. # warning You will run into problems if you use # warning gphoto2 with a serial (RS232) camera in # warning combination with Konqueror (KDE) or Nautilus (GNOME). # warning This will *not* concern USB cameras. # endif #endif return (GP_OK); }
struct cdevsw * devvn_refthread(struct vnode *vp, struct cdev **devp) { struct cdevsw *csw; struct cdev_priv *cdp; mtx_assert(&devmtx, MA_NOTOWNED); csw = NULL; dev_lock(); [1] *devp = vp->v_rdev; if (*devp != NULL) { [2] cdp = (*devp)->si_priv; [3] if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) { [4] csw = (*devp)->si_devsw; if (csw != NULL) [5] (*devp)->si_threadcount++; }
static int exynos_frequency_lock(struct device *dev) { unsigned int level, cpufreq = 600; /* 200 ~ 1400 */ unsigned int busfreq = 400200; /* 100100 ~ 400200 */ int ret = 0; struct device *busdev = dev_get("exynos-busfreq"); if (atomic_read(&umts_link_pm_data.freqlock) == 0) { /* cpu frequency lock */ ret = exynos_cpufreq_get_level(cpufreq * 1000, &level); if (ret < 0) { mif_err("ERR: exynos_cpufreq_get_level fail: %d\n", ret); goto exit; } ret = exynos_cpufreq_lock(DVFS_LOCK_ID_USB_IF, level); if (ret < 0) { mif_err("ERR: exynos_cpufreq_lock fail: %d\n", ret); goto exit; } /* bus frequncy lock */ if (!busdev) { mif_err("ERR: busdev is not exist\n"); ret = -ENODEV; goto exit; } ret = dev_lock(busdev, dev, busfreq); if (ret < 0) { mif_err("ERR: dev_lock error: %d\n", ret); goto exit; } /* lock minimum number of cpu cores */ cpufreq_pegasusq_min_cpu_lock(2); atomic_set(&umts_link_pm_data.freqlock, 1); mif_debug("level=%d, cpufreq=%d MHz, busfreq=%06d\n", level, cpufreq, busfreq); } exit: return ret; }
static void mxr_graph_stream_set(struct mxr_layer *layer, int en) { struct mxr_device *mdev = layer->mdev; exynos_cpufreq_lock_freq(en, MAX_CPU_FREQ); #ifdef CONFIG_BUSFREQ_OPP if (en) dev_lock(mdev->bus_dev, mdev->dev, BUSFREQ_400MHZ); else dev_unlock(mdev->bus_dev, mdev->dev); #endif #ifdef CONFIG_ARM_EXYNOS4_BUS_DEVFREQ exynos4_busfreq_lock(!en); #endif mxr_reg_graph_layer_stream(layer->mdev, layer->idx, en); }
/** * exynos_tc_volt - locks or frees vdd_arm, vdd_mif/int and vdd_g3d for * temperature compensation. * * This function limits or free voltage of cpufreq, busfreq, and mali driver * according to 2nd arguments. */ static int exynos_tc_volt(struct s5p_tmu_info *info, int enable) { struct s5p_platform_tmu *data; static int usage; int ret = 0; if (!info || !(info->dev)) return -EPERM; data = info->dev->platform_data; if (enable == usage) { pr_debug("TMU: already is %s.\n", enable ? "locked" : "unlocked"); return 0; } if (enable) { ret = exynos_cpufreq_lock(DVFS_LOCK_ID_TMU, info->cpulevel_tc); if (ret) goto err_lock; #ifdef CONFIG_BUSFREQ_OPP ret = dev_lock(info->bus_dev, info->dev, info->busfreq_tc); if (ret) goto err_lock; #endif } else { exynos_cpufreq_lock_free(DVFS_LOCK_ID_TMU); #ifdef CONFIG_BUSFREQ_OPP ret = dev_unlock(info->bus_dev, info->dev); if (ret) goto err_unlock; #endif } usage = enable; pr_info("TMU: %s is ok!\n", enable ? "lock" : "unlock"); return ret; err_lock: err_unlock: pr_err("TMU: %s is fail.\n", enable ? "lock" : "unlock"); return ret; }
struct cdevsw * dev_refthread(struct cdev *dev) { struct cdevsw *csw; struct cdev_priv *cdp; mtx_assert(&devmtx, MA_NOTOWNED); dev_lock(); csw = dev->si_devsw; if (csw != NULL) { cdp = cdev2priv(dev); if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) dev->si_threadcount++; else csw = NULL; } dev_unlock(); return (csw); }
struct cdevsw * devvn_refthread(struct vnode *vp, struct cdev **devp, int *ref) { struct cdevsw *csw; struct cdev_priv *cdp; struct cdev *dev; mtx_assert(&devmtx, MA_NOTOWNED); if ((vp->v_vflag & VV_ETERNALDEV) != 0) { dev = vp->v_rdev; if (dev == NULL) return (NULL); KASSERT((dev->si_flags & SI_ETERNAL) != 0, ("Not eternal cdev")); *ref = 0; csw = dev->si_devsw; KASSERT(csw != NULL, ("Eternal cdev is destroyed")); *devp = dev; return (csw); } csw = NULL; dev_lock(); dev = vp->v_rdev; if (dev == NULL) { dev_unlock(); return (NULL); } cdp = cdev2priv(dev); if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) { csw = dev->si_devsw; if (csw != NULL) dev->si_threadcount++; } dev_unlock(); if (csw != NULL) { *devp = dev; *ref = 1; } return (csw); }
struct cdevsw * devvn_refthread(struct vnode *vp, struct cdev **devp) { struct cdevsw *csw; struct cdev_priv *cdp; mtx_assert(&devmtx, MA_NOTOWNED); csw = NULL; dev_lock(); *devp = vp->v_rdev; if (*devp != NULL) { cdp = cdev2priv(*devp); if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) { csw = (*devp)->si_devsw; if (csw != NULL) (*devp)->si_threadcount++; } } dev_unlock(); return (csw); }
static void set_dvfs_lock(struct wacom_i2c *wac_i2c, bool on) { if (on) { if (!wac_i2c->dvfs_lock_status) { cancel_delayed_work(&wac_i2c->dvfs_work); dev_lock(wac_i2c->bus_dev, wac_i2c->dev, SEC_BUS_LOCK_FREQ2); exynos_cpufreq_lock(DVFS_LOCK_ID_PEN, wac_i2c->cpufreq_level); wac_i2c->dvfs_lock_status = true; schedule_delayed_work(&wac_i2c->dvfs_work, msecs_to_jiffies(SEC_DVFS_LOCK_TIMEOUT_MS)); } } else { if (wac_i2c->dvfs_lock_status) { schedule_delayed_work(&wac_i2c->dvfs_work, msecs_to_jiffies(SEC_DVFS_LOCK_TIMEOUT_MS)); wac_i2c->dvfs_lock_status = false; } } }
int s3cfb_enable_window(struct s3cfb_global *fbdev, int id) { struct s3cfb_window *win = fbdev->fb[id]->par; #ifdef CONFIG_BUSFREQ_OPP if (soc_is_exynos4212() || soc_is_exynos4412()) { if (id != CONFIG_FB_S5P_DEFAULT_WINDOW) dev_lock(fbdev->bus_dev, fbdev->dev, 133133); } #endif if (!win->enabled) atomic_inc(&fbdev->enabled_win); if (s3cfb_window_on(fbdev, id)) { win->enabled = 0; return -EFAULT; } else { win->enabled = 1; return 0; } }
static void set_dvfs_lock(struct wacom_i2c *wac_i2c, bool on) { if (on) { cancel_delayed_work(&wac_i2c->dvfs_work); if (!wac_i2c->dvfs_lock_status) { #ifdef SEC_BUS_LOCK #if defined(CONFIG_MACH_P4NOTE) dev_lock(wac_i2c->bus_dev, wac_i2c->dev, BUS_LOCK_FREQ); #else exynos4_busfreq_lock(DVFS_LOCK_ID_PEN, BUS_L1); #endif #endif /* SEC_BUS_LOCK */ exynos_cpufreq_lock(DVFS_LOCK_ID_PEN, wac_i2c->cpufreq_level); wac_i2c->dvfs_lock_status = true; } } else { if (wac_i2c->dvfs_lock_status) schedule_delayed_work(&wac_i2c->dvfs_work, SEC_DVFS_LOCK_TIMEOUT * HZ); } }
struct cdevsw * dev_refthread(struct cdev *dev, int *ref) { struct cdevsw *csw; struct cdev_priv *cdp; mtx_assert(&devmtx, MA_NOTOWNED); if ((dev->si_flags & SI_ETERNAL) != 0) { *ref = 0; return (dev->si_devsw); } dev_lock(); csw = dev->si_devsw; if (csw != NULL) { cdp = cdev2priv(dev); if ((cdp->cdp_flags & CDP_SCHED_DTR) == 0) atomic_add_long(&dev->si_threadcount, 1); else csw = NULL; } dev_unlock(); *ref = 1; return (csw); }
void dev_rel(struct cdev *dev) { int flag = 0; mtx_assert(&devmtx, MA_NOTOWNED); dev_lock(); dev->si_refcount--; KASSERT(dev->si_refcount >= 0, ("dev_rel(%s) gave negative count", devtoname(dev))); #if 0 if (dev->si_usecount == 0 && (dev->si_flags & SI_CHEAPCLONE) && (dev->si_flags & SI_NAMED)) ; else #endif if (dev->si_devsw == NULL && dev->si_refcount == 0) { LIST_REMOVE(dev, si_list); flag = 1; } dev_unlock(); if (flag) devfs_free(dev); }
/*:::::*/ int fb_SerialOpen ( FB_FILE *handle, int iPort, FB_SERIAL_OPTIONS *options, const char *pszDevice, void **ppvHandle ) { int res = FB_RTERROR_OK; int DesiredAccess = O_RDWR|O_NOCTTY|O_NONBLOCK; int SerialFD = (-1); char DeviceName[512]; struct termios oldserp, nwserp; speed_t TermSpeed; #ifdef HAS_LOCKDEV pid_t plckid; #endif /* The IRQ stuff is not supported on Linux ... */ if( options->IRQNumber != 0 ) { return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } res = fb_ErrorSetNum( FB_RTERROR_OK ); switch( handle->access ) { case FB_FILE_ACCESS_READ: DesiredAccess |= O_RDONLY; break; case FB_FILE_ACCESS_WRITE: DesiredAccess |= O_WRONLY; break; case FB_FILE_ACCESS_READWRITE: /* fall through */ case FB_FILE_ACCESS_ANY: DesiredAccess |= O_RDWR; break; } DeviceName[0] = '\0'; if( iPort == 0 ) { if( strcasecmp(pszDevice, "COM") == 0 ) { strcpy( DeviceName, "/dev/modem" ); } else { strcpy( DeviceName, pszDevice ); } } else { sprintf(DeviceName, "/dev/ttyS%d", (iPort-1)); } /* Setting speed baud line */ TermSpeed = get_speed(options->uiSpeed); if( TermSpeed == BADSPEED ) { return fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } #ifdef HAS_LOCKDEV if( dev_testlock(DeviceName) ) { return fb_ErrorSetNum( FB_RTERROR_FILENOTFOUND ); } plckid = dev_lock(DeviceName); if( plckid < 0 ) { return fb_ErrorSetNum( FB_RTERROR_FILENOTFOUND ); } #endif alarm(SERIAL_TIMEOUT); SerialFD = open( DeviceName, DesiredAccess ); alarm(0); if( SerialFD < 0) { #ifdef HAS_LOCKDEV dev_unlock(DeviceName, plckid); #endif return fb_ErrorSetNum( FB_RTERROR_FILENOTFOUND ); } /* !!!FIXME!!! Lock file handle (handle->lock) pending, you can use fcnctl or flock functions */ /* Make the file descriptor asynchronous */ /* fcntl(SerialFD, F_SETFL, FASYNC); */ /* Save old status of serial port discipline */ if( tcgetattr ( SerialFD, &oldserp ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } /* Discard data write/read in serial port not transmitted */ if( tcflush( SerialFD, TCIOFLUSH) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } /* Inittialize new struct termios with old values */ if( tcgetattr ( SerialFD, &nwserp ) ) { res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } /* Set timeouts * Timeout not are defined in UNIX termio/s * set CTS > 0 enable CTSRTS flow control, * other are ignored are setting for default in open function * !!!FIXME!!! ??? */ /* setup generic serial port configuration */ if( res == FB_RTERROR_OK ) { /* Initialize */ nwserp.c_cflag |= CREAD; /* Enable receiver */ nwserp.c_iflag &= ~(IXON | IXOFF | IXANY); /* Disable Software Flow Control */ nwserp.c_cflag |= CREAD; /* Enable receiver */ if( options->AddLF ) { /*With AddFl Set, Process Canonical output/input */ nwserp.c_lflag |= (ICANON|OPOST|ONLCR); /* Postprocess output and map newline at nl/cr */ } else { /* Set raw tty settings */ cfmakeraw(&nwserp); nwserp.c_cc[VMIN] = 1 ; /* Wait min for 1 char */ nwserp.c_cc[VTIME] = 0 ; /* Not use timeout */ } if( options->KeepDTREnabled ) nwserp.c_cflag &= ~(HUPCL); /* Not Hangup (set DTR) on last close */ else nwserp.c_cflag |= (HUPCL); /* Hangup (drop DTR) on last close */ /* CD (Carrier Detect) and DS (Data Set Ready) are modem signal * in UNIXes the flag CLOCAL attend the modem signals. Quickly, if your conection is * a modem telephony device active CD[0-n] and DS[0-n] * else for local conections set CD0 or DS0 */ /* DS and CD are ignored */ if( options->DurationDSR || options->DurationCD ) { nwserp.c_cflag &= ~(CLOCAL); } else { nwserp.c_cflag |= CLOCAL; /* Ignore modem control Lines */ } /* Termios not manage timeout for CTS, but understand RTSCTS flow control * if DurationCTS is greater zero CTSRTS flow will be activate */ if( options->DurationCTS != 0 && !options->SuppressRTS ) nwserp.c_cflag |= CRTSCTS; else nwserp.c_cflag &= ~CRTSCTS; /* Setting speed baud and other serial parameters */ nwserp.c_cflag |= TermSpeed ; /* Set size word 5,6,7,8 sonly support */ nwserp.c_cflag &= ~(CSIZE); switch ( options->uiDataBits) { case 5: nwserp.c_cflag |= CS5 ; break; case 6: nwserp.c_cflag |= CS6 ; break; case 7: nwserp.c_cflag |= CS7 ; break; case 8: /* fall through */ default: nwserp.c_cflag |= CS8 ; } /* Setting parity, 1.5 StopBit not supported */ switch ( options->Parity ) { case FB_SERIAL_PARITY_NONE: nwserp.c_cflag &= ~(PARENB); break; /* 7bits and Space parity is the same (7S1) that (8N1) 8 bits without parity */ case FB_SERIAL_PARITY_SPACE: nwserp.c_cflag &= ~(PARENB); nwserp.c_cflag |= CS8; break; /* !!!FIXME!!! I'm not sure for mark parity, set the input line. Fix me! for output */ case FB_SERIAL_PARITY_MARK: nwserp.c_iflag |= (PARMRK); /* fall through */ case FB_SERIAL_PARITY_EVEN: nwserp.c_iflag |= (INPCK | ISTRIP); nwserp.c_cflag |= PARENB; break; case FB_SERIAL_PARITY_ODD: nwserp.c_iflag |= (INPCK | ISTRIP); nwserp.c_cflag |= (PARENB|PARODD); break; } /* Ignore all parity errors, can be dangerous */ if ( options->IgnoreAllErrors ) { nwserp.c_iflag |= (IGNPAR); } else { nwserp.c_iflag &= ~(IGNPAR); } switch ( options->StopBits ) { case FB_SERIAL_STOP_BITS_1: nwserp.c_cflag &= ~(CSTOPB); break; /* 1.5 Stop not support 2 Stop bits assumed */ case FB_SERIAL_STOP_BITS_1_5: /* fall through */ case FB_SERIAL_STOP_BITS_2: nwserp.c_cflag |= CSTOPB; break; } /* If not RTS hardware flow, sotfware IXANY softflow assumed */ if( options->SuppressRTS ) { nwserp.c_iflag &= ~(IXON | IXOFF | IXANY); nwserp.c_iflag |= (IXON | IXANY); } if( res == FB_RTERROR_OK ) { /* Active set serial parameters */ if( tcsetattr( SerialFD, TCSAFLUSH, &nwserp ) ) res = fb_ErrorSetNum( FB_RTERROR_ILLEGALFUNCTIONCALL ); } } /* error? */ if( res != FB_RTERROR_OK ) { #ifdef HAS_LOCKDEV dev_unlock(DeviceName, plckid); #endif tcsetattr( SerialFD, TCSAFLUSH, &oldserp); /* Restore old parameter of serial line */ close(SerialFD); } else { LINUX_SERIAL_INFO *pInfo = (LINUX_SERIAL_INFO *) calloc( 1, sizeof(LINUX_SERIAL_INFO) ); DBG_ASSERT( ppvHandle!=NULL ); *ppvHandle = pInfo; pInfo->sfd = SerialFD; pInfo->oldtty = oldserp; pInfo->newtty = nwserp; #ifdef HAS_LOCKDEV pInfo->pplckid = plckid; #endif pInfo->iPort = iPort; pInfo->pOptions = options; } return res; }
static long fimg2d_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int ret = 0; struct fimg2d_context *ctx; struct fimg2d_platdata *pdata; union { struct fimg2d_blit *blit; struct fimg2d_version ver; } u; ctx = file->private_data; if (!ctx) { printk(KERN_ERR "[%s] missing ctx\n", __func__); return -EFAULT; } switch (cmd) { case FIMG2D_BITBLT_BLIT: fimg2d_debug("FIMG2D_BITBLT_BLIT ctx: %p\n", ctx); u.blit = (struct fimg2d_blit *)arg; #ifdef CONFIG_BUSFREQ_OPP #if defined(CONFIG_CPU_EXYNOS4412) dev_lock(info->bus_dev, info->dev, 160160); #endif #endif ret = fimg2d_add_command(info, ctx, u.blit); if (!ret) fimg2d_request_bitblt(ctx); #ifdef PERF_PROFILE perf_print(ctx, u.blit->seq_no); perf_clear(ctx); #endif #ifdef CONFIG_BUSFREQ_OPP #if defined(CONFIG_CPU_EXYNOS4412) dev_unlock(info->bus_dev, info->dev); #endif #endif break; case FIMG2D_BITBLT_SYNC: fimg2d_debug("FIMG2D_BITBLT_SYNC ctx: %p\n", ctx); /* FIXME: */ break; case FIMG2D_BITBLT_VERSION: fimg2d_debug("FIMG2D_BITBLT_VERSION ctx: %p\n", ctx); pdata = to_fimg2d_plat(info->dev); u.ver.hw = pdata->hw_ver; u.ver.sw = 0; fimg2d_debug("fimg2d version, hw: 0x%x sw: 0x%x\n", u.ver.hw, u.ver.sw); if (copy_to_user((void *)arg, &u.ver, sizeof(u.ver))) return -EFAULT; break; default: printk(KERN_ERR "[%s] unknown ioctl\n", __func__); ret = -EFAULT; break; } return ret; }