diff options
Diffstat (limited to 'kernel/drivers/staging/media')
36 files changed, 489 insertions, 1880 deletions
diff --git a/kernel/drivers/staging/media/Kconfig b/kernel/drivers/staging/media/Kconfig index 96498b7fc..14697686e 100644 --- a/kernel/drivers/staging/media/Kconfig +++ b/kernel/drivers/staging/media/Kconfig @@ -25,8 +25,6 @@ source "drivers/staging/media/cxd2099/Kconfig" source "drivers/staging/media/davinci_vpfe/Kconfig" -source "drivers/staging/media/dt3155v4l/Kconfig" - source "drivers/staging/media/mn88472/Kconfig" source "drivers/staging/media/mn88473/Kconfig" diff --git a/kernel/drivers/staging/media/Makefile b/kernel/drivers/staging/media/Makefile index a9006bcb4..34c557b4c 100644 --- a/kernel/drivers/staging/media/Makefile +++ b/kernel/drivers/staging/media/Makefile @@ -1,7 +1,6 @@ obj-$(CONFIG_I2C_BCM2048) += bcm2048/ obj-$(CONFIG_DVB_CXD2099) += cxd2099/ obj-$(CONFIG_LIRC_STAGING) += lirc/ -obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ obj-$(CONFIG_DVB_MN88472) += mn88472/ diff --git a/kernel/drivers/staging/media/bcm2048/radio-bcm2048.c b/kernel/drivers/staging/media/bcm2048/radio-bcm2048.c index e9d0691b2..b10d6016b 100644 --- a/kernel/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/kernel/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -217,7 +217,7 @@ #define BCM2048_FREQ_ERROR_FLOOR -20 #define BCM2048_FREQ_ERROR_ROOF 20 -/* -60 dB is reported as full signal strenght */ +/* -60 dB is reported as full signal strength */ #define BCM2048_RSSI_LEVEL_BASE -60 #define BCM2048_RSSI_LEVEL_ROOF -100 #define BCM2048_RSSI_LEVEL_ROOF_NEG 100 @@ -342,14 +342,6 @@ static struct region_info region_configs[] = { .deemphasis = 50, .region = 3, }, - /* Japan wide band */ - { - .channel_spacing = 10, - .bottom_frequency = 76000, - .top_frequency = 108000, - .deemphasis = 50, - .region = 4, - }, }; /* @@ -621,7 +613,7 @@ static int bcm2048_set_fm_frequency(struct bcm2048_device *bdev, u32 frequency) static int bcm2048_get_fm_frequency(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -666,7 +658,7 @@ static int bcm2048_set_fm_af_frequency(struct bcm2048_device *bdev, static int bcm2048_get_fm_af_frequency(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -741,6 +733,18 @@ static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region) mutex_lock(&bdev->mutex); bdev->region_info = region_configs[region]; + + if (region_configs[region].bottom_frequency < 87500) + bdev->cache_fm_ctrl |= BCM2048_BAND_SELECT; + else + bdev->cache_fm_ctrl &= ~BCM2048_BAND_SELECT; + + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL, + bdev->cache_fm_ctrl); + if (err) { + mutex_unlock(&bdev->mutex); + goto done; + } mutex_unlock(&bdev->mutex); if (bdev->frequency < region_configs[region].bottom_frequency || @@ -1048,7 +1052,7 @@ static int bcm2048_set_rds_b_block_mask(struct bcm2048_device *bdev, u16 mask) static int bcm2048_get_rds_b_block_mask(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -1084,7 +1088,7 @@ static int bcm2048_set_rds_b_block_match(struct bcm2048_device *bdev, static int bcm2048_get_rds_b_block_match(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -1119,7 +1123,7 @@ static int bcm2048_set_rds_pi_mask(struct bcm2048_device *bdev, u16 mask) static int bcm2048_get_rds_pi_mask(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -1154,7 +1158,7 @@ static int bcm2048_set_rds_pi_match(struct bcm2048_device *bdev, u16 match) static int bcm2048_get_rds_pi_match(struct bcm2048_device *bdev) { int err; - u8 lsb, msb; + u8 lsb = 0, msb = 0; mutex_lock(&bdev->mutex); @@ -1189,7 +1193,7 @@ static int bcm2048_set_fm_rds_mask(struct bcm2048_device *bdev, u16 mask) static int bcm2048_get_fm_rds_mask(struct bcm2048_device *bdev) { int err; - u8 value0, value1; + u8 value0 = 0, value1 = 0; mutex_lock(&bdev->mutex); @@ -1207,7 +1211,7 @@ static int bcm2048_get_fm_rds_mask(struct bcm2048_device *bdev) static int bcm2048_get_fm_rds_flags(struct bcm2048_device *bdev) { int err; - u8 value0, value1; + u8 value0 = 0, value1 = 0; mutex_lock(&bdev->mutex); @@ -1235,7 +1239,7 @@ static int bcm2048_get_region_top_frequency(struct bcm2048_device *bdev) static int bcm2048_set_fm_best_tune_mode(struct bcm2048_device *bdev, u8 mode) { int err; - u8 value; + u8 value = 0; mutex_lock(&bdev->mutex); @@ -1909,7 +1913,7 @@ unlock: static void bcm2048_work(struct work_struct *work) { struct bcm2048_device *bdev; - u8 flag_lsb, flag_msb, flags; + u8 flag_lsb = 0, flag_msb = 0, flags; bdev = container_of(work, struct bcm2048_device, work); bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG0, &flag_lsb); @@ -2468,7 +2472,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv, } else { /* * RSSI level -60 dB is defined to report full - * signal strenght + * signal strength */ rssi = bcm2048_get_fm_rssi(bdev); if (rssi >= BCM2048_RSSI_LEVEL_BASE) { @@ -2593,7 +2597,7 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bcm2048_device *bdev; - int err, skip_release = 0; + int err; bdev = kzalloc(sizeof(*bdev), GFP_KERNEL); if (!bdev) { @@ -2646,7 +2650,6 @@ free_sysfs: bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs)); free_registration: video_unregister_device(&bdev->videodev); - skip_release = 1; free_irq: if (client->irq) free_irq(client->irq, bdev); diff --git a/kernel/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/kernel/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 1bbb90ce0..b1dfa2ccc 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/kernel/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -79,7 +79,7 @@ static int ipipe_set_lutdpc_params(struct vpfe_ipipe_device *ipipe, void *param) } dev = ipipe->subdev.v4l2_dev->dev; - dpc_param = (struct vpfe_ipipe_lutdpc *)param; + dpc_param = param; lutdpc->en = dpc_param->en; lutdpc->repl_white = dpc_param->repl_white; lutdpc->dpc_size = dpc_param->dpc_size; @@ -96,7 +96,7 @@ success: static int ipipe_get_lutdpc_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_lutdpc *lut_param = (struct vpfe_ipipe_lutdpc *)param; + struct vpfe_ipipe_lutdpc *lut_param = param; struct vpfe_ipipe_lutdpc *lutdpc = &ipipe->config.lutdpc; lut_param->en = lutdpc->en; @@ -171,7 +171,7 @@ static int ipipe_validate_otfdpc_params(struct vpfe_ipipe_otfdpc *dpc_param) static int ipipe_set_otfdpc_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_otfdpc *dpc_param = (struct vpfe_ipipe_otfdpc *)param; + struct vpfe_ipipe_otfdpc *dpc_param = param; struct vpfe_ipipe_otfdpc *otfdpc = &ipipe->config.otfdpc; struct device *dev; @@ -194,7 +194,7 @@ success: static int ipipe_get_otfdpc_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_otfdpc *dpc_param = (struct vpfe_ipipe_otfdpc *)param; + struct vpfe_ipipe_otfdpc *dpc_param = param; struct vpfe_ipipe_otfdpc *otfdpc = &ipipe->config.otfdpc; memcpy(dpc_param, otfdpc, sizeof(struct vpfe_ipipe_otfdpc)); @@ -226,7 +226,7 @@ static int ipipe_validate_nf_params(struct vpfe_ipipe_nf *nf_param) static int ipipe_set_nf_params(struct vpfe_ipipe_device *ipipe, unsigned int id, void *param) { - struct vpfe_ipipe_nf *nf_param = (struct vpfe_ipipe_nf *)param; + struct vpfe_ipipe_nf *nf_param = param; struct vpfe_ipipe_nf *nf = &ipipe->config.nf1; struct device *dev; @@ -264,7 +264,7 @@ static int ipipe_set_nf2_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_get_nf_params(struct vpfe_ipipe_device *ipipe, unsigned int id, void *param) { - struct vpfe_ipipe_nf *nf_param = (struct vpfe_ipipe_nf *)param; + struct vpfe_ipipe_nf *nf_param = param; struct vpfe_ipipe_nf *nf = &ipipe->config.nf1; if (id == IPIPE_D2F_2ND) @@ -299,7 +299,7 @@ static int ipipe_validate_gic_params(struct vpfe_ipipe_gic *gic) static int ipipe_set_gic_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gic *gic_param = (struct vpfe_ipipe_gic *)param; + struct vpfe_ipipe_gic *gic_param = param; struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_gic *gic = &ipipe->config.gic; @@ -322,7 +322,7 @@ success: static int ipipe_get_gic_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gic *gic_param = (struct vpfe_ipipe_gic *)param; + struct vpfe_ipipe_gic *gic_param = param; struct vpfe_ipipe_gic *gic = &ipipe->config.gic; memcpy(gic_param, gic, sizeof(struct vpfe_ipipe_gic)); @@ -351,7 +351,7 @@ static int ipipe_validate_wb_params(struct vpfe_ipipe_wb *wbal) static int ipipe_set_wb_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_wb *wb_param = (struct vpfe_ipipe_wb *)param; + struct vpfe_ipipe_wb *wb_param = param; struct vpfe_ipipe_wb *wbal = &ipipe->config.wbal; if (!wb_param) { @@ -377,7 +377,7 @@ success: static int ipipe_get_wb_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_wb *wb_param = (struct vpfe_ipipe_wb *)param; + struct vpfe_ipipe_wb *wb_param = param; struct vpfe_ipipe_wb *wbal = &ipipe->config.wbal; memcpy(wb_param, wbal, sizeof(struct vpfe_ipipe_wb)); @@ -407,7 +407,7 @@ static int ipipe_validate_cfa_params(struct vpfe_ipipe_cfa *cfa) static int ipipe_set_cfa_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_cfa *cfa_param = (struct vpfe_ipipe_cfa *)param; + struct vpfe_ipipe_cfa *cfa_param = param; struct vpfe_ipipe_cfa *cfa = &ipipe->config.cfa; if (!cfa_param) { @@ -428,7 +428,7 @@ success: static int ipipe_get_cfa_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_cfa *cfa_param = (struct vpfe_ipipe_cfa *)param; + struct vpfe_ipipe_cfa *cfa_param = param; struct vpfe_ipipe_cfa *cfa = &ipipe->config.cfa; memcpy(cfa_param, cfa, sizeof(struct vpfe_ipipe_cfa)); @@ -498,7 +498,7 @@ static int ipipe_set_rgb2rgb_params(struct vpfe_ipipe_device *ipipe, struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_rgb2rgb *rgb2rgb_param; - rgb2rgb_param = (struct vpfe_ipipe_rgb2rgb *)param; + rgb2rgb_param = param; if (id == IPIPE_RGB2RGB_2) rgb2rgb = &ipipe->config.rgb2rgb2; @@ -551,7 +551,7 @@ static int ipipe_get_rgb2rgb_params(struct vpfe_ipipe_device *ipipe, struct vpfe_ipipe_rgb2rgb *rgb2rgb = &ipipe->config.rgb2rgb1; struct vpfe_ipipe_rgb2rgb *rgb2rgb_param; - rgb2rgb_param = (struct vpfe_ipipe_rgb2rgb *)param; + rgb2rgb_param = param; if (id == IPIPE_RGB2RGB_2) rgb2rgb = &ipipe->config.rgb2rgb2; @@ -634,7 +634,7 @@ ipipe_validate_gamma_params(struct vpfe_ipipe_gamma *gamma, struct device *dev) static int ipipe_set_gamma_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gamma *gamma_param = (struct vpfe_ipipe_gamma *)param; + struct vpfe_ipipe_gamma *gamma_param = param; struct vpfe_ipipe_gamma *gamma = &ipipe->config.gamma; struct device *dev = ipipe->subdev.v4l2_dev->dev; int table_size; @@ -678,7 +678,7 @@ success: static int ipipe_get_gamma_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gamma *gamma_param = (struct vpfe_ipipe_gamma *)param; + struct vpfe_ipipe_gamma *gamma_param = param; struct vpfe_ipipe_gamma *gamma = &ipipe->config.gamma; struct device *dev = ipipe->subdev.v4l2_dev->dev; int table_size; @@ -737,7 +737,7 @@ static int ipipe_validate_3d_lut_params(struct vpfe_ipipe_3d_lut *lut) static int ipipe_get_3d_lut_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_3d_lut *lut_param = (struct vpfe_ipipe_3d_lut *)param; + struct vpfe_ipipe_3d_lut *lut_param = param; struct vpfe_ipipe_3d_lut *lut = &ipipe->config.lut; struct device *dev = ipipe->subdev.v4l2_dev->dev; @@ -757,7 +757,7 @@ static int ipipe_get_3d_lut_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_set_3d_lut_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_3d_lut *lut_param = (struct vpfe_ipipe_3d_lut *)param; + struct vpfe_ipipe_3d_lut *lut_param = param; struct vpfe_ipipe_3d_lut *lut = &ipipe->config.lut; struct device *dev = ipipe->subdev.v4l2_dev->dev; @@ -831,7 +831,7 @@ ipipe_set_rgb2yuv_params(struct vpfe_ipipe_device *ipipe, void *param) struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_rgb2yuv *rgb2yuv_param; - rgb2yuv_param = (struct vpfe_ipipe_rgb2yuv *)param; + rgb2yuv_param = param; if (!rgb2yuv_param) { /* Defaults for rgb2yuv conversion */ const struct vpfe_ipipe_rgb2yuv rgb2yuv_defaults = { @@ -871,7 +871,7 @@ ipipe_get_rgb2yuv_params(struct vpfe_ipipe_device *ipipe, void *param) struct vpfe_ipipe_rgb2yuv *rgb2yuv = &ipipe->config.rgb2yuv; struct vpfe_ipipe_rgb2yuv *rgb2yuv_param; - rgb2yuv_param = (struct vpfe_ipipe_rgb2yuv *)param; + rgb2yuv_param = param; memcpy(rgb2yuv_param, rgb2yuv, sizeof(struct vpfe_ipipe_rgb2yuv)); return 0; } @@ -896,7 +896,7 @@ static int ipipe_validate_gbce_params(struct vpfe_ipipe_gbce *gbce) static int ipipe_set_gbce_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gbce *gbce_param = (struct vpfe_ipipe_gbce *)param; + struct vpfe_ipipe_gbce *gbce_param = param; struct vpfe_ipipe_gbce *gbce = &ipipe->config.gbce; struct device *dev = ipipe->subdev.v4l2_dev->dev; @@ -917,7 +917,7 @@ static int ipipe_set_gbce_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_get_gbce_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_gbce *gbce_param = (struct vpfe_ipipe_gbce *)param; + struct vpfe_ipipe_gbce *gbce_param = param; struct vpfe_ipipe_gbce *gbce = &ipipe->config.gbce; struct device *dev = ipipe->subdev.v4l2_dev->dev; @@ -950,7 +950,7 @@ ipipe_set_yuv422_conv_params(struct vpfe_ipipe_device *ipipe, void *param) struct vpfe_ipipe_yuv422_conv *yuv422_conv_param; struct device *dev = ipipe->subdev.v4l2_dev->dev; - yuv422_conv_param = (struct vpfe_ipipe_yuv422_conv *)param; + yuv422_conv_param = param; if (!yuv422_conv_param) { memset(yuv422_conv, 0, sizeof(struct vpfe_ipipe_yuv422_conv)); yuv422_conv->chrom_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE; @@ -974,7 +974,7 @@ ipipe_get_yuv422_conv_params(struct vpfe_ipipe_device *ipipe, void *param) struct vpfe_ipipe_yuv422_conv *yuv422_conv = &ipipe->config.yuv422_conv; struct vpfe_ipipe_yuv422_conv *yuv422_conv_param; - yuv422_conv_param = (struct vpfe_ipipe_yuv422_conv *)param; + yuv422_conv_param = param; memcpy(yuv422_conv_param, yuv422_conv, sizeof(struct vpfe_ipipe_yuv422_conv)); @@ -1018,7 +1018,7 @@ static int ipipe_validate_yee_params(struct vpfe_ipipe_yee *yee) static int ipipe_set_yee_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_yee *yee_param = (struct vpfe_ipipe_yee *)param; + struct vpfe_ipipe_yee *yee_param = param; struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_yee *yee = &ipipe->config.yee; @@ -1039,7 +1039,7 @@ static int ipipe_set_yee_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_get_yee_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_yee *yee_param = (struct vpfe_ipipe_yee *)param; + struct vpfe_ipipe_yee *yee_param = param; struct vpfe_ipipe_yee *yee = &ipipe->config.yee; yee_param->en = yee->en; @@ -1081,7 +1081,7 @@ static int ipipe_validate_car_params(struct vpfe_ipipe_car *car) static int ipipe_set_car_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_car *car_param = (struct vpfe_ipipe_car *)param; + struct vpfe_ipipe_car *car_param = param; struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_car *car = &ipipe->config.car; @@ -1102,7 +1102,7 @@ static int ipipe_set_car_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_get_car_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_car *car_param = (struct vpfe_ipipe_car *)param; + struct vpfe_ipipe_car *car_param = param; struct vpfe_ipipe_car *car = &ipipe->config.car; memcpy(car_param, car, sizeof(struct vpfe_ipipe_car)); @@ -1119,7 +1119,7 @@ static int ipipe_validate_cgs_params(struct vpfe_ipipe_cgs *cgs) static int ipipe_set_cgs_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_cgs *cgs_param = (struct vpfe_ipipe_cgs *)param; + struct vpfe_ipipe_cgs *cgs_param = param; struct device *dev = ipipe->subdev.v4l2_dev->dev; struct vpfe_ipipe_cgs *cgs = &ipipe->config.cgs; @@ -1140,7 +1140,7 @@ static int ipipe_set_cgs_params(struct vpfe_ipipe_device *ipipe, void *param) static int ipipe_get_cgs_params(struct vpfe_ipipe_device *ipipe, void *param) { - struct vpfe_ipipe_cgs *cgs_param = (struct vpfe_ipipe_cgs *)param; + struct vpfe_ipipe_cgs *cgs_param = param; struct vpfe_ipipe_cgs *cgs = &ipipe->config.cgs; memcpy(cgs_param, cgs, sizeof(struct vpfe_ipipe_cgs)); diff --git a/kernel/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/kernel/drivers/staging/media/davinci_vpfe/dm365_resizer.c index b6498137d..acb293ed9 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/kernel/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -321,6 +321,7 @@ static int resizer_configure_output_win(struct vpfe_resizer_device *resizer) outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE]; + memset(&output_specs, 0x0, sizeof(struct vpfe_rsz_output_spec)); output_specs.vst_y = param->user_config.vst; if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16) output_specs.vst_c = param->user_config.vst; diff --git a/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index 57426199a..01df0683e 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -294,7 +294,7 @@ static void vpfe_detach_irq(struct vpfe_device *vpfe_dev) */ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev) { - int ret = 0; + int ret; ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, 0, "vpfe_capture0", vpfe_dev); diff --git a/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h b/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h index 2632a806c..8ad8d743f 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h +++ b/kernel/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h @@ -67,8 +67,6 @@ struct vpfe_device { /* CCDC IRQs used when CCDC/ISIF output to SDRAM */ unsigned int ccdc_irq0; unsigned int ccdc_irq1; - /* maximum video memory that is available*/ - unsigned int video_limit; /* media device */ struct media_device media_dev; /* ccdc subdevice */ diff --git a/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.c b/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.c index 06d48d5eb..0fdff9162 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -27,9 +27,6 @@ #include "vpfe.h" #include "vpfe_mc_capture.h" -/* minimum number of buffers needed in cont-mode */ -#define MIN_NUM_BUFFERS 3 - static int debug; /* get v4l2 subdev pointer to external subdev which is active */ @@ -431,8 +428,8 @@ vpfe_video_get_next_buffer(struct vpfe_video_device *video) struct vpfe_cap_buffer, list); list_del(&video->next_frm->list); - video->next_frm->vb.state = VB2_BUF_STATE_ACTIVE; - return vb2_dma_contig_plane_dma_addr(&video->next_frm->vb, 0); + video->next_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE; + return vb2_dma_contig_plane_dma_addr(&video->next_frm->vb.vb2_buf, 0); } /* schedule the next buffer which is available on dma queue */ @@ -451,8 +448,8 @@ void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video) video->cur_frm = video->next_frm; list_del(&video->next_frm->list); - video->next_frm->vb.state = VB2_BUF_STATE_ACTIVE; - addr = vb2_dma_contig_plane_dma_addr(&video->next_frm->vb, 0); + video->next_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE; + addr = vb2_dma_contig_plane_dma_addr(&video->next_frm->vb.vb2_buf, 0); video->ops->queue(vpfe_dev, addr); video->state = VPFE_VIDEO_BUFFER_QUEUED; } @@ -463,7 +460,7 @@ void vpfe_video_schedule_bottom_field(struct vpfe_video_device *video) struct vpfe_device *vpfe_dev = video->vpfe_dev; unsigned long addr; - addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb, 0); + addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb.vb2_buf, 0); addr += video->field_off; video->ops->queue(vpfe_dev, addr); } @@ -473,8 +470,8 @@ void vpfe_video_process_buffer_complete(struct vpfe_video_device *video) { struct vpfe_pipeline *pipe = &video->pipe; - do_gettimeofday(&video->cur_frm->vb.v4l2_buf.timestamp); - vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_DONE); + v4l2_get_timestamp(&video->cur_frm->vb.timestamp); + vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE); if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) video->cur_frm = video->next_frm; } @@ -1081,27 +1078,21 @@ vpfe_g_dv_timings(struct file *file, void *fh, * the buffer nbuffers and buffer size */ static int -vpfe_buffer_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, +vpfe_buffer_queue_setup(struct vb2_queue *vq, const void *parg, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) { struct vpfe_fh *fh = vb2_get_drv_priv(vq); struct vpfe_video_device *video = fh->video; struct vpfe_device *vpfe_dev = video->vpfe_dev; - struct vpfe_pipeline *pipe = &video->pipe; unsigned long size; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_queue_setup\n"); size = video->fmt.fmt.pix.sizeimage; - if (vpfe_dev->video_limit) { - while (size * *nbuffers > vpfe_dev->video_limit) - (*nbuffers)--; - } - if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) { - if (*nbuffers < MIN_NUM_BUFFERS) - *nbuffers = MIN_NUM_BUFFERS; - } + if (vq->num_buffers + *nbuffers < 3) + *nbuffers = 3 - vq->num_buffers; + *nplanes = 1; sizes[0] = size; alloc_ctxs[0] = video->alloc_ctx; @@ -1147,12 +1138,13 @@ static int vpfe_buffer_prepare(struct vb2_buffer *vb) static void vpfe_buffer_queue(struct vb2_buffer *vb) { + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); /* Get the file handle object and device object */ struct vpfe_fh *fh = vb2_get_drv_priv(vb->vb2_queue); struct vpfe_video_device *video = fh->video; struct vpfe_device *vpfe_dev = video->vpfe_dev; struct vpfe_pipeline *pipe = &video->pipe; - struct vpfe_cap_buffer *buf = container_of(vb, + struct vpfe_cap_buffer *buf = container_of(vbuf, struct vpfe_cap_buffer, vb); unsigned long flags; unsigned long empty; @@ -1212,10 +1204,10 @@ static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count) /* Remove buffer from the buffer queue */ list_del(&video->cur_frm->list); /* Mark state of the current frame to active */ - video->cur_frm->vb.state = VB2_BUF_STATE_ACTIVE; + video->cur_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE; /* Initialize field_id and started member */ video->field_id = 0; - addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb, 0); + addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb.vb2_buf, 0); video->ops->queue(vpfe_dev, addr); video->state = VPFE_VIDEO_BUFFER_QUEUED; @@ -1223,10 +1215,12 @@ static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret) { struct vpfe_cap_buffer *buf, *tmp; - vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_QUEUED); + vb2_buffer_done(&video->cur_frm->vb.vb2_buf, + VB2_BUF_STATE_QUEUED); list_for_each_entry_safe(buf, tmp, &video->dma_queue, list) { list_del(&buf->list); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); + vb2_buffer_done(&buf->vb.vb2_buf, + VB2_BUF_STATE_QUEUED); } goto unlock_out; } @@ -1243,7 +1237,8 @@ streamoff: static int vpfe_buffer_init(struct vb2_buffer *vb) { - struct vpfe_cap_buffer *buf = container_of(vb, + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct vpfe_cap_buffer *buf = container_of(vbuf, struct vpfe_cap_buffer, vb); INIT_LIST_HEAD(&buf->list); @@ -1258,13 +1253,14 @@ static void vpfe_stop_streaming(struct vb2_queue *vq) /* release all active buffers */ if (video->cur_frm == video->next_frm) { - vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_ERROR); + vb2_buffer_done(&video->cur_frm->vb.vb2_buf, + VB2_BUF_STATE_ERROR); } else { if (video->cur_frm != NULL) - vb2_buffer_done(&video->cur_frm->vb, + vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR); if (video->next_frm != NULL) - vb2_buffer_done(&video->next_frm->vb, + vb2_buffer_done(&video->next_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR); } @@ -1272,16 +1268,18 @@ static void vpfe_stop_streaming(struct vb2_queue *vq) video->next_frm = list_entry(video->dma_queue.next, struct vpfe_cap_buffer, list); list_del(&video->next_frm->list); - vb2_buffer_done(&video->next_frm->vb, VB2_BUF_STATE_ERROR); + vb2_buffer_done(&video->next_frm->vb.vb2_buf, + VB2_BUF_STATE_ERROR); } } static void vpfe_buf_cleanup(struct vb2_buffer *vb) { + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct vpfe_fh *fh = vb2_get_drv_priv(vb->vb2_queue); struct vpfe_video_device *video = fh->video; struct vpfe_device *vpfe_dev = video->vpfe_dev; - struct vpfe_cap_buffer *buf = container_of(vb, + struct vpfe_cap_buffer *buf = container_of(vbuf, struct vpfe_cap_buffer, vb); v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buf_cleanup\n"); @@ -1346,6 +1344,7 @@ static int vpfe_reqbufs(struct file *file, void *priv, q->ops = &video_qops; q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpfe_cap_buffer); + q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; ret = vb2_queue_init(q); if (ret) { diff --git a/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.h b/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.h index 1b1b6c4a5..673cefe3e 100644 --- a/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/kernel/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -22,6 +22,7 @@ #ifndef _DAVINCI_VPFE_VIDEO_H #define _DAVINCI_VPFE_VIDEO_H +#include <media/videobuf2-v4l2.h> #include <media/videobuf2-dma-contig.h> struct vpfe_device; @@ -72,7 +73,7 @@ struct vpfe_pipeline { container_of(vdev, struct vpfe_video_device, video_dev) struct vpfe_cap_buffer { - struct vb2_buffer vb; + struct vb2_v4l2_buffer vb; struct list_head list; }; diff --git a/kernel/drivers/staging/media/dt3155v4l/Kconfig b/kernel/drivers/staging/media/dt3155v4l/Kconfig deleted file mode 100644 index 2d496001b..000000000 --- a/kernel/drivers/staging/media/dt3155v4l/Kconfig +++ /dev/null @@ -1,29 +0,0 @@ -config VIDEO_DT3155 - tristate "DT3155 frame grabber, Video4Linux interface" - depends on PCI && VIDEO_DEV && VIDEO_V4L2 - depends on HAS_DMA - select VIDEOBUF2_DMA_CONTIG - default n - ---help--- - Enables dt3155 device driver for the DataTranslation DT3155 frame grabber. - Say Y here if you have this hardware. - In doubt, say N. - - To compile this driver as a module, choose M here: the - module will be called dt3155v4l. - -config DT3155_CCIR - bool "Selects CCIR/50Hz vertical refresh" - depends on VIDEO_DT3155 - default y - ---help--- - Select it for CCIR/50Hz (European region), - or leave it unselected for RS-170/60Hz (North America). - -config DT3155_STREAMING - bool "Selects streaming capture method" - depends on VIDEO_DT3155 - default y - ---help--- - Select it if you want to use streaming of memory mapped buffers - or leave it unselected if you want to use read method (one copy more). diff --git a/kernel/drivers/staging/media/dt3155v4l/Makefile b/kernel/drivers/staging/media/dt3155v4l/Makefile deleted file mode 100644 index ce7a3ec2f..000000000 --- a/kernel/drivers/staging/media/dt3155v4l/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l.o diff --git a/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.c b/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.c deleted file mode 100644 index 52a8ffe56..000000000 --- a/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.c +++ /dev/null @@ -1,981 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Marin Mitov * - * mitov@issp.bas.bg * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include <linux/module.h> -#include <linux/version.h> -#include <linux/stringify.h> -#include <linux/delay.h> -#include <linux/kthread.h> -#include <linux/slab.h> -#include <media/v4l2-dev.h> -#include <media/v4l2-ioctl.h> -#include <media/v4l2-common.h> -#include <media/videobuf2-dma-contig.h> - -#include "dt3155v4l.h" - -#define DT3155_DEVICE_ID 0x1223 - -/* DT3155_CHUNK_SIZE is 4M (2^22) 8 full size buffers */ -#define DT3155_CHUNK_SIZE (1U << 22) - -#define DT3155_COH_FLAGS (GFP_KERNEL | GFP_DMA32 | __GFP_COLD | __GFP_NOWARN) - -#define DT3155_BUF_SIZE (768 * 576) - -#ifdef CONFIG_DT3155_STREAMING -#define DT3155_CAPTURE_METHOD V4L2_CAP_STREAMING -#else -#define DT3155_CAPTURE_METHOD V4L2_CAP_READWRITE -#endif - -/* global initializers (for all boards) */ -#ifdef CONFIG_DT3155_CCIR -static const u8 csr2_init = VT_50HZ; -#define DT3155_CURRENT_NORM V4L2_STD_625_50 -static const unsigned int img_width = 768; -static const unsigned int img_height = 576; -static const unsigned int frames_per_sec = 25; -static const struct v4l2_fmtdesc frame_std[] = { - { - .index = 0, - .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, - .flags = 0, - .description = "CCIR/50Hz 8 bits gray", - .pixelformat = V4L2_PIX_FMT_GREY, - }, -}; -#else -static const u8 csr2_init = VT_60HZ; -#define DT3155_CURRENT_NORM V4L2_STD_525_60 -static const unsigned int img_width = 640; -static const unsigned int img_height = 480; -static const unsigned int frames_per_sec = 30; -static const struct v4l2_fmtdesc frame_std[] = { - { - .index = 0, - .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, - .flags = 0, - .description = "RS-170/60Hz 8 bits gray", - .pixelformat = V4L2_PIX_FMT_GREY, - }, -}; -#endif - -#define NUM_OF_FORMATS ARRAY_SIZE(frame_std) - -static u8 config_init = ACQ_MODE_EVEN; - -/** - * read_i2c_reg - reads an internal i2c register - * - * @addr: dt3155 mmio base address - * @index: index (internal address) of register to read - * @data: pointer to byte the read data will be placed in - * - * returns: zero on success or error code - * - * This function starts reading the specified (by index) register - * and busy waits for the process to finish. The result is placed - * in a byte pointed by data. - */ -static int -read_i2c_reg(void __iomem *addr, u8 index, u8 *data) -{ - u32 tmp = index; - - iowrite32((tmp<<17) | IIC_READ, addr + IIC_CSR2); - mmiowb(); - udelay(45); /* wait at least 43 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) - return -EIO; /* error: NEW_CYCLE not cleared */ - tmp = ioread32(addr + IIC_CSR1); - if (tmp & DIRECT_ABORT) { - /* reset DIRECT_ABORT bit */ - iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; /* error: DIRECT_ABORT set */ - } - *data = tmp>>24; - return 0; -} - -/** - * write_i2c_reg - writes to an internal i2c register - * - * @addr: dt3155 mmio base address - * @index: index (internal address) of register to read - * @data: data to be written - * - * returns: zero on success or error code - * - * This function starts writting the specified (by index) register - * and busy waits for the process to finish. - */ -static int -write_i2c_reg(void __iomem *addr, u8 index, u8 data) -{ - u32 tmp = index; - - iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2); - mmiowb(); - udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) - return -EIO; /* error: NEW_CYCLE not cleared */ - if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { - /* reset DIRECT_ABORT bit */ - iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; /* error: DIRECT_ABORT set */ - } - return 0; -} - -/** - * write_i2c_reg_nowait - writes to an internal i2c register - * - * @addr: dt3155 mmio base address - * @index: index (internal address) of register to read - * @data: data to be written - * - * This function starts writting the specified (by index) register - * and then returns. - */ -static void write_i2c_reg_nowait(void __iomem *addr, u8 index, u8 data) -{ - u32 tmp = index; - - iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2); - mmiowb(); -} - -/** - * wait_i2c_reg - waits the read/write to finish - * - * @addr: dt3155 mmio base address - * - * returns: zero on success or error code - * - * This function waits reading/writting to finish. - */ -static int wait_i2c_reg(void __iomem *addr) -{ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) - udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ - if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) - return -EIO; /* error: NEW_CYCLE not cleared */ - if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { - /* reset DIRECT_ABORT bit */ - iowrite32(DIRECT_ABORT, addr + IIC_CSR1); - return -EIO; /* error: DIRECT_ABORT set */ - } - return 0; -} - -static int -dt3155_start_acq(struct dt3155_priv *pd) -{ - struct vb2_buffer *vb = pd->curr_buf; - dma_addr_t dma_addr; - - dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0); - iowrite32(dma_addr, pd->regs + EVEN_DMA_START); - iowrite32(dma_addr + img_width, pd->regs + ODD_DMA_START); - iowrite32(img_width, pd->regs + EVEN_DMA_STRIDE); - iowrite32(img_width, pd->regs + ODD_DMA_STRIDE); - /* enable interrupts, clear all irq flags */ - iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START | - FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR); - iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | - FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD, - pd->regs + CSR1); - wait_i2c_reg(pd->regs); - write_i2c_reg(pd->regs, CONFIG, pd->config); - write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); - write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); - - /* start the board */ - write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | BUSY_ODD); - return 0; /* success */ -} - -/* - * driver-specific callbacks (vb2_ops) - */ -static int -dt3155_queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt, - unsigned int *num_buffers, unsigned int *num_planes, - unsigned int sizes[], void *alloc_ctxs[]) - -{ - struct dt3155_priv *pd = vb2_get_drv_priv(q); - void *ret; - - if (*num_buffers == 0) - *num_buffers = 1; - *num_planes = 1; - sizes[0] = img_width * img_height; - if (pd->q->alloc_ctx[0]) - return 0; - ret = vb2_dma_contig_init_ctx(&pd->pdev->dev); - if (IS_ERR(ret)) - return PTR_ERR(ret); - pd->q->alloc_ctx[0] = ret; - return 0; -} - -static void -dt3155_wait_prepare(struct vb2_queue *q) -{ - struct dt3155_priv *pd = vb2_get_drv_priv(q); - - mutex_unlock(pd->vdev.lock); -} - -static void -dt3155_wait_finish(struct vb2_queue *q) -{ - struct dt3155_priv *pd = vb2_get_drv_priv(q); - - mutex_lock(pd->vdev.lock); -} - -static int -dt3155_buf_prepare(struct vb2_buffer *vb) -{ - vb2_set_plane_payload(vb, 0, img_width * img_height); - return 0; -} - -static void -dt3155_stop_streaming(struct vb2_queue *q) -{ - struct dt3155_priv *pd = vb2_get_drv_priv(q); - struct vb2_buffer *vb; - - spin_lock_irq(&pd->lock); - while (!list_empty(&pd->dmaq)) { - vb = list_first_entry(&pd->dmaq, typeof(*vb), done_entry); - list_del(&vb->done_entry); - vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); - } - spin_unlock_irq(&pd->lock); - msleep(45); /* irq hendler will stop the hardware */ -} - -static void -dt3155_buf_queue(struct vb2_buffer *vb) -{ - struct dt3155_priv *pd = vb2_get_drv_priv(vb->vb2_queue); - - /* pd->q->streaming = 1 when dt3155_buf_queue() is invoked */ - spin_lock_irq(&pd->lock); - if (pd->curr_buf) - list_add_tail(&vb->done_entry, &pd->dmaq); - else { - pd->curr_buf = vb; - dt3155_start_acq(pd); - } - spin_unlock_irq(&pd->lock); -} -/* - * end driver-specific callbacks - */ - -static const struct vb2_ops q_ops = { - .queue_setup = dt3155_queue_setup, - .wait_prepare = dt3155_wait_prepare, - .wait_finish = dt3155_wait_finish, - .buf_prepare = dt3155_buf_prepare, - .stop_streaming = dt3155_stop_streaming, - .buf_queue = dt3155_buf_queue, -}; - -static irqreturn_t -dt3155_irq_handler_even(int irq, void *dev_id) -{ - struct dt3155_priv *ipd = dev_id; - struct vb2_buffer *ivb; - dma_addr_t dma_addr; - u32 tmp; - - tmp = ioread32(ipd->regs + INT_CSR) & (FLD_START | FLD_END_ODD); - if (!tmp) - return IRQ_NONE; /* not our irq */ - if ((tmp & FLD_START) && !(tmp & FLD_END_ODD)) { - iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START, - ipd->regs + INT_CSR); - ipd->field_count++; - return IRQ_HANDLED; /* start of field irq */ - } - if ((tmp & FLD_START) && (tmp & FLD_END_ODD)) - ipd->stats.start_before_end++; - /* check for corrupted fields */ -/* write_i2c_reg(ipd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); */ -/* write_i2c_reg(ipd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); */ - tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD); - if (tmp) { - ipd->stats.corrupted_fields++; - iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | - FLD_DN_ODD | FLD_DN_EVEN | - CAP_CONT_EVEN | CAP_CONT_ODD, - ipd->regs + CSR1); - mmiowb(); - } - - spin_lock(&ipd->lock); - if (ipd->curr_buf) { - v4l2_get_timestamp(&ipd->curr_buf->v4l2_buf.timestamp); - ipd->curr_buf->v4l2_buf.sequence = (ipd->field_count) >> 1; - vb2_buffer_done(ipd->curr_buf, VB2_BUF_STATE_DONE); - } - - if (!ipd->q->streaming || list_empty(&ipd->dmaq)) - goto stop_dma; - ivb = list_first_entry(&ipd->dmaq, typeof(*ivb), done_entry); - list_del(&ivb->done_entry); - ipd->curr_buf = ivb; - dma_addr = vb2_dma_contig_plane_dma_addr(ivb, 0); - iowrite32(dma_addr, ipd->regs + EVEN_DMA_START); - iowrite32(dma_addr + img_width, ipd->regs + ODD_DMA_START); - iowrite32(img_width, ipd->regs + EVEN_DMA_STRIDE); - iowrite32(img_width, ipd->regs + ODD_DMA_STRIDE); - mmiowb(); - /* enable interrupts, clear all irq flags */ - iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START | - FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR); - spin_unlock(&ipd->lock); - return IRQ_HANDLED; - -stop_dma: - ipd->curr_buf = NULL; - /* stop the board */ - write_i2c_reg_nowait(ipd->regs, CSR2, ipd->csr2); - iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | - FLD_DN_ODD | FLD_DN_EVEN, ipd->regs + CSR1); - /* disable interrupts, clear all irq flags */ - iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR); - spin_unlock(&ipd->lock); - return IRQ_HANDLED; -} - -static int -dt3155_open(struct file *filp) -{ - int ret = 0; - struct dt3155_priv *pd = video_drvdata(filp); - - if (mutex_lock_interruptible(&pd->mux)) - return -ERESTARTSYS; - if (!pd->users) { - pd->q = kzalloc(sizeof(*pd->q), GFP_KERNEL); - if (!pd->q) { - ret = -ENOMEM; - goto err_alloc_queue; - } - pd->q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - pd->q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - pd->q->io_modes = VB2_READ | VB2_MMAP; - pd->q->ops = &q_ops; - pd->q->mem_ops = &vb2_dma_contig_memops; - pd->q->drv_priv = pd; - pd->curr_buf = NULL; - pd->field_count = 0; - ret = vb2_queue_init(pd->q); - if (ret < 0) - goto err_request_irq; - INIT_LIST_HEAD(&pd->dmaq); - spin_lock_init(&pd->lock); - /* disable all irqs, clear all irq flags */ - iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, - pd->regs + INT_CSR); - ret = request_irq(pd->pdev->irq, dt3155_irq_handler_even, - IRQF_SHARED, DT3155_NAME, pd); - if (ret) - goto err_request_irq; - } - pd->users++; - mutex_unlock(&pd->mux); - return 0; /* success */ -err_request_irq: - kfree(pd->q); - pd->q = NULL; -err_alloc_queue: - mutex_unlock(&pd->mux); - return ret; -} - -static int -dt3155_release(struct file *filp) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - mutex_lock(&pd->mux); - pd->users--; - BUG_ON(pd->users < 0); - if (!pd->users) { - vb2_queue_release(pd->q); - free_irq(pd->pdev->irq, pd); - if (pd->q->alloc_ctx[0]) - vb2_dma_contig_cleanup_ctx(pd->q->alloc_ctx[0]); - kfree(pd->q); - pd->q = NULL; - } - mutex_unlock(&pd->mux); - return 0; -} - -static ssize_t -dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff) -{ - struct dt3155_priv *pd = video_drvdata(filp); - ssize_t res; - - if (mutex_lock_interruptible(&pd->mux)) - return -ERESTARTSYS; - res = vb2_read(pd->q, user, size, loff, filp->f_flags & O_NONBLOCK); - mutex_unlock(&pd->mux); - return res; -} - -static unsigned int -dt3155_poll(struct file *filp, struct poll_table_struct *polltbl) -{ - struct dt3155_priv *pd = video_drvdata(filp); - unsigned int res; - - mutex_lock(&pd->mux); - res = vb2_poll(pd->q, filp, polltbl); - mutex_unlock(&pd->mux); - return res; -} - -static int -dt3155_mmap(struct file *filp, struct vm_area_struct *vma) -{ - struct dt3155_priv *pd = video_drvdata(filp); - int res; - - if (mutex_lock_interruptible(&pd->mux)) - return -ERESTARTSYS; - res = vb2_mmap(pd->q, vma); - mutex_unlock(&pd->mux); - return res; -} - -static const struct v4l2_file_operations dt3155_fops = { - .owner = THIS_MODULE, - .open = dt3155_open, - .release = dt3155_release, - .read = dt3155_read, - .poll = dt3155_poll, - .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ - .mmap = dt3155_mmap, -}; - -static int -dt3155_ioc_streamon(struct file *filp, void *p, enum v4l2_buf_type type) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_streamon(pd->q, type); -} - -static int -dt3155_ioc_streamoff(struct file *filp, void *p, enum v4l2_buf_type type) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_streamoff(pd->q, type); -} - -static int -dt3155_ioc_querycap(struct file *filp, void *p, struct v4l2_capability *cap) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - strcpy(cap->driver, DT3155_NAME); - strcpy(cap->card, DT3155_NAME " frame grabber"); - sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev)); - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | - DT3155_CAPTURE_METHOD; - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; - return 0; -} - -static int -dt3155_ioc_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f) -{ - if (f->index >= NUM_OF_FORMATS) - return -EINVAL; - *f = frame_std[f->index]; - return 0; -} - -static int -dt3155_ioc_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) -{ - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - f->fmt.pix.width = img_width; - f->fmt.pix.height = img_height; - f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY; - f->fmt.pix.field = V4L2_FIELD_NONE; - f->fmt.pix.bytesperline = f->fmt.pix.width; - f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height; - f->fmt.pix.colorspace = 0; - f->fmt.pix.priv = 0; - return 0; -} - -static int -dt3155_ioc_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) -{ - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - if (f->fmt.pix.width == img_width && - f->fmt.pix.height == img_height && - f->fmt.pix.pixelformat == V4L2_PIX_FMT_GREY && - f->fmt.pix.field == V4L2_FIELD_NONE && - f->fmt.pix.bytesperline == f->fmt.pix.width && - f->fmt.pix.sizeimage == f->fmt.pix.width * f->fmt.pix.height) - return 0; - else - return -EINVAL; -} - -static int -dt3155_ioc_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) -{ - return dt3155_ioc_g_fmt_vid_cap(filp, p, f); -} - -static int -dt3155_ioc_reqbufs(struct file *filp, void *p, struct v4l2_requestbuffers *b) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_reqbufs(pd->q, b); -} - -static int -dt3155_ioc_querybuf(struct file *filp, void *p, struct v4l2_buffer *b) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_querybuf(pd->q, b); -} - -static int -dt3155_ioc_qbuf(struct file *filp, void *p, struct v4l2_buffer *b) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_qbuf(pd->q, b); -} - -static int -dt3155_ioc_dqbuf(struct file *filp, void *p, struct v4l2_buffer *b) -{ - struct dt3155_priv *pd = video_drvdata(filp); - - return vb2_dqbuf(pd->q, b, filp->f_flags & O_NONBLOCK); -} - -static int -dt3155_ioc_querystd(struct file *filp, void *p, v4l2_std_id *norm) -{ - *norm = DT3155_CURRENT_NORM; - return 0; -} - -static int -dt3155_ioc_g_std(struct file *filp, void *p, v4l2_std_id *norm) -{ - *norm = DT3155_CURRENT_NORM; - return 0; -} - -static int -dt3155_ioc_s_std(struct file *filp, void *p, v4l2_std_id norm) -{ - if (norm & DT3155_CURRENT_NORM) - return 0; - return -EINVAL; -} - -static int -dt3155_ioc_enum_input(struct file *filp, void *p, struct v4l2_input *input) -{ - if (input->index) - return -EINVAL; - strcpy(input->name, "Coax in"); - input->type = V4L2_INPUT_TYPE_CAMERA; - /* - * FIXME: input->std = 0 according to v4l2 API - * VIDIOC_G_STD, VIDIOC_S_STD, VIDIOC_QUERYSTD and VIDIOC_ENUMSTD - * should return -EINVAL - */ - input->std = DT3155_CURRENT_NORM; - input->status = 0;/* FIXME: add sync detection & V4L2_IN_ST_NO_H_LOCK */ - return 0; -} - -static int -dt3155_ioc_g_input(struct file *filp, void *p, unsigned int *i) -{ - *i = 0; - return 0; -} - -static int -dt3155_ioc_s_input(struct file *filp, void *p, unsigned int i) -{ - if (i) - return -EINVAL; - return 0; -} - -static int -dt3155_ioc_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms) -{ - if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - parms->parm.capture.capturemode = 0; - parms->parm.capture.timeperframe.numerator = 1001; - parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000; - parms->parm.capture.extendedmode = 0; - parms->parm.capture.readbuffers = 1; /* FIXME: 2 buffers? */ - return 0; -} - -static int -dt3155_ioc_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms) -{ - if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - parms->parm.capture.capturemode = 0; - parms->parm.capture.timeperframe.numerator = 1001; - parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000; - parms->parm.capture.extendedmode = 0; - parms->parm.capture.readbuffers = 1; /* FIXME: 2 buffers? */ - return 0; -} - -static const struct v4l2_ioctl_ops dt3155_ioctl_ops = { - .vidioc_streamon = dt3155_ioc_streamon, - .vidioc_streamoff = dt3155_ioc_streamoff, - .vidioc_querycap = dt3155_ioc_querycap, -/* - .vidioc_g_priority = dt3155_ioc_g_priority, - .vidioc_s_priority = dt3155_ioc_s_priority, -*/ - .vidioc_enum_fmt_vid_cap = dt3155_ioc_enum_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = dt3155_ioc_try_fmt_vid_cap, - .vidioc_g_fmt_vid_cap = dt3155_ioc_g_fmt_vid_cap, - .vidioc_s_fmt_vid_cap = dt3155_ioc_s_fmt_vid_cap, - .vidioc_reqbufs = dt3155_ioc_reqbufs, - .vidioc_querybuf = dt3155_ioc_querybuf, - .vidioc_qbuf = dt3155_ioc_qbuf, - .vidioc_dqbuf = dt3155_ioc_dqbuf, - .vidioc_querystd = dt3155_ioc_querystd, - .vidioc_g_std = dt3155_ioc_g_std, - .vidioc_s_std = dt3155_ioc_s_std, - .vidioc_enum_input = dt3155_ioc_enum_input, - .vidioc_g_input = dt3155_ioc_g_input, - .vidioc_s_input = dt3155_ioc_s_input, -/* - .vidioc_queryctrl = dt3155_ioc_queryctrl, - .vidioc_g_ctrl = dt3155_ioc_g_ctrl, - .vidioc_s_ctrl = dt3155_ioc_s_ctrl, - .vidioc_querymenu = dt3155_ioc_querymenu, - .vidioc_g_ext_ctrls = dt3155_ioc_g_ext_ctrls, - .vidioc_s_ext_ctrls = dt3155_ioc_s_ext_ctrls, -*/ - .vidioc_g_parm = dt3155_ioc_g_parm, - .vidioc_s_parm = dt3155_ioc_s_parm, -/* - .vidioc_cropcap = dt3155_ioc_cropcap, - .vidioc_g_crop = dt3155_ioc_g_crop, - .vidioc_s_crop = dt3155_ioc_s_crop, - .vidioc_enum_framesizes = dt3155_ioc_enum_framesizes, - .vidioc_enum_frameintervals = dt3155_ioc_enum_frameintervals, -*/ -}; - -static int -dt3155_init_board(struct pci_dev *pdev) -{ - struct dt3155_priv *pd = pci_get_drvdata(pdev); - void *buf_cpu; - dma_addr_t buf_dma; - int i; - u8 tmp; - - pci_set_master(pdev); /* dt3155 needs it */ - - /* resetting the adapter */ - iowrite32(FLD_CRPT_ODD | FLD_CRPT_EVEN | FLD_DN_ODD | FLD_DN_EVEN, - pd->regs + CSR1); - mmiowb(); - msleep(20); - - /* initializing adaper registers */ - iowrite32(FIFO_EN | SRST, pd->regs + CSR1); - mmiowb(); - iowrite32(0xEEEEEE01, pd->regs + EVEN_PIXEL_FMT); - iowrite32(0xEEEEEE01, pd->regs + ODD_PIXEL_FMT); - iowrite32(0x00000020, pd->regs + FIFO_TRIGER); - iowrite32(0x00000103, pd->regs + XFER_MODE); - iowrite32(0, pd->regs + RETRY_WAIT_CNT); - iowrite32(0, pd->regs + INT_CSR); - iowrite32(1, pd->regs + EVEN_FLD_MASK); - iowrite32(1, pd->regs + ODD_FLD_MASK); - iowrite32(0, pd->regs + MASK_LENGTH); - iowrite32(0x0005007C, pd->regs + FIFO_FLAG_CNT); - iowrite32(0x01010101, pd->regs + IIC_CLK_DUR); - mmiowb(); - - /* verifying that we have a DT3155 board (not just a SAA7116 chip) */ - read_i2c_reg(pd->regs, DT_ID, &tmp); - if (tmp != DT3155_ID) - return -ENODEV; - - /* initialize AD LUT */ - write_i2c_reg(pd->regs, AD_ADDR, 0); - for (i = 0; i < 256; i++) - write_i2c_reg(pd->regs, AD_LUT, i); - - /* initialize ADC references */ - /* FIXME: pos_ref & neg_ref depend on VT_50HZ */ - write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG); - write_i2c_reg(pd->regs, AD_CMD, VIDEO_CNL_1 | SYNC_CNL_1 | SYNC_LVL_3); - write_i2c_reg(pd->regs, AD_ADDR, AD_POS_REF); - write_i2c_reg(pd->regs, AD_CMD, 34); - write_i2c_reg(pd->regs, AD_ADDR, AD_NEG_REF); - write_i2c_reg(pd->regs, AD_CMD, 0); - - /* initialize PM LUT */ - write_i2c_reg(pd->regs, CONFIG, pd->config | PM_LUT_PGM); - for (i = 0; i < 256; i++) { - write_i2c_reg(pd->regs, PM_LUT_ADDR, i); - write_i2c_reg(pd->regs, PM_LUT_DATA, i); - } - write_i2c_reg(pd->regs, CONFIG, pd->config | PM_LUT_PGM | PM_LUT_SEL); - for (i = 0; i < 256; i++) { - write_i2c_reg(pd->regs, PM_LUT_ADDR, i); - write_i2c_reg(pd->regs, PM_LUT_DATA, i); - } - write_i2c_reg(pd->regs, CONFIG, pd->config); /* ACQ_MODE_EVEN */ - - /* select channel 1 for input and set sync level */ - write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG); - write_i2c_reg(pd->regs, AD_CMD, VIDEO_CNL_1 | SYNC_CNL_1 | SYNC_LVL_3); - - /* allocate memory, and initialize the DMA machine */ - buf_cpu = dma_alloc_coherent(&pdev->dev, DT3155_BUF_SIZE, &buf_dma, - GFP_KERNEL); - if (!buf_cpu) - return -ENOMEM; - iowrite32(buf_dma, pd->regs + EVEN_DMA_START); - iowrite32(buf_dma, pd->regs + ODD_DMA_START); - iowrite32(0, pd->regs + EVEN_DMA_STRIDE); - iowrite32(0, pd->regs + ODD_DMA_STRIDE); - - /* Perform a pseudo even field acquire */ - iowrite32(FIFO_EN | SRST | CAP_CONT_ODD, pd->regs + CSR1); - write_i2c_reg(pd->regs, CSR2, pd->csr2 | SYNC_SNTL); - write_i2c_reg(pd->regs, CONFIG, pd->config); - write_i2c_reg(pd->regs, EVEN_CSR, CSR_SNGL); - write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | SYNC_SNTL); - msleep(100); - read_i2c_reg(pd->regs, CSR2, &tmp); - write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE); - write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE); - write_i2c_reg(pd->regs, CSR2, pd->csr2); - iowrite32(FIFO_EN | SRST | FLD_DN_EVEN | FLD_DN_ODD, pd->regs + CSR1); - - /* deallocate memory */ - dma_free_coherent(&pdev->dev, DT3155_BUF_SIZE, buf_cpu, buf_dma); - if (tmp & BUSY_EVEN) - return -EIO; - return 0; -} - -static struct video_device dt3155_vdev = { - .name = DT3155_NAME, - .fops = &dt3155_fops, - .ioctl_ops = &dt3155_ioctl_ops, - .minor = -1, - .release = video_device_release_empty, - .tvnorms = DT3155_CURRENT_NORM, -}; - -/* same as in drivers/base/dma-coherent.c */ -struct dma_coherent_mem { - void *virt_base; - dma_addr_t device_base; - int size; - int flags; - unsigned long *bitmap; -}; - -static int -dt3155_alloc_coherent(struct device *dev, size_t size, int flags) -{ - struct dma_coherent_mem *mem; - dma_addr_t dev_base; - int pages = size >> PAGE_SHIFT; - int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long); - - if ((flags & DMA_MEMORY_MAP) == 0) - goto out; - if (!size) - goto out; - if (dev->dma_mem) - goto out; - - mem = kzalloc(sizeof(*mem), GFP_KERNEL); - if (!mem) - goto out; - mem->virt_base = dma_alloc_coherent(dev, size, &dev_base, - DT3155_COH_FLAGS); - if (!mem->virt_base) - goto err_alloc_coherent; - mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!mem->bitmap) - goto err_bitmap; - - /* coherent_dma_mask is already set to 32 bits */ - mem->device_base = dev_base; - mem->size = pages; - mem->flags = flags; - dev->dma_mem = mem; - return DMA_MEMORY_MAP; - -err_bitmap: - dma_free_coherent(dev, size, mem->virt_base, dev_base); -err_alloc_coherent: - kfree(mem); -out: - return 0; -} - -static void -dt3155_free_coherent(struct device *dev) -{ - struct dma_coherent_mem *mem = dev->dma_mem; - - if (!mem) - return; - dev->dma_mem = NULL; - dma_free_coherent(dev, mem->size << PAGE_SHIFT, - mem->virt_base, mem->device_base); - kfree(mem->bitmap); - kfree(mem); -} - -static int -dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) -{ - int err; - struct dt3155_priv *pd; - - err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); - if (err) - return -ENODEV; - pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL); - if (!pd) - return -ENOMEM; - - pd->vdev = dt3155_vdev; - pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */ - video_set_drvdata(&pd->vdev, pd); /* for use in video_fops */ - pd->users = 0; - pd->pdev = pdev; - INIT_LIST_HEAD(&pd->dmaq); - mutex_init(&pd->mux); - pd->vdev.lock = &pd->mux; /* for locking v4l2_file_operations */ - spin_lock_init(&pd->lock); - pd->csr2 = csr2_init; - pd->config = config_init; - err = pci_enable_device(pdev); - if (err) - return err; - err = pci_request_region(pdev, 0, pci_name(pdev)); - if (err) - goto err_req_region; - pd->regs = pci_iomap(pdev, 0, pci_resource_len(pd->pdev, 0)); - if (!pd->regs) { - err = -ENOMEM; - goto err_pci_iomap; - } - err = dt3155_init_board(pdev); - if (err) - goto err_init_board; - err = video_register_device(&pd->vdev, VFL_TYPE_GRABBER, -1); - if (err) - goto err_init_board; - if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE, - DMA_MEMORY_MAP)) - dev_info(&pdev->dev, "preallocated 8 buffers\n"); - dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev.minor); - return 0; /* success */ - -err_init_board: - pci_iounmap(pdev, pd->regs); -err_pci_iomap: - pci_release_region(pdev, 0); -err_req_region: - pci_disable_device(pdev); - return err; -} - -static void -dt3155_remove(struct pci_dev *pdev) -{ - struct dt3155_priv *pd = pci_get_drvdata(pdev); - - dt3155_free_coherent(&pdev->dev); - video_unregister_device(&pd->vdev); - pci_iounmap(pdev, pd->regs); - pci_release_region(pdev, 0); - pci_disable_device(pdev); -} - -static const struct pci_device_id pci_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, DT3155_DEVICE_ID) }, - { 0, /* zero marks the end */ }, -}; -MODULE_DEVICE_TABLE(pci, pci_ids); - -static struct pci_driver pci_driver = { - .name = DT3155_NAME, - .id_table = pci_ids, - .probe = dt3155_probe, - .remove = dt3155_remove, -}; - -module_pci_driver(pci_driver); - -MODULE_DESCRIPTION("video4linux pci-driver for dt3155 frame grabber"); -MODULE_AUTHOR("Marin Mitov <mitov@issp.bas.bg>"); -MODULE_VERSION(DT3155_VERSION); -MODULE_LICENSE("GPL"); diff --git a/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.h b/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.h deleted file mode 100644 index 96f01a0c7..000000000 --- a/kernel/drivers/staging/media/dt3155v4l/dt3155v4l.h +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2010 by Marin Mitov * - * mitov@issp.bas.bg * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -/* DT3155 header file */ -#ifndef _DT3155_H_ -#define _DT3155_H_ - -#ifdef __KERNEL__ - -#include <linux/pci.h> -#include <linux/interrupt.h> - -#define DT3155_NAME "dt3155" -#define DT3155_VER_MAJ 1 -#define DT3155_VER_MIN 1 -#define DT3155_VER_EXT 0 -#define DT3155_VERSION __stringify(DT3155_VER_MAJ) "." \ - __stringify(DT3155_VER_MIN) "." \ - __stringify(DT3155_VER_EXT) - -/* DT3155 Base Register offsets (memory mapped) */ -#define EVEN_DMA_START 0x00 -#define ODD_DMA_START 0x0C -#define EVEN_DMA_STRIDE 0x18 -#define ODD_DMA_STRIDE 0x24 -#define EVEN_PIXEL_FMT 0x30 -#define ODD_PIXEL_FMT 0x34 -#define FIFO_TRIGER 0x38 -#define XFER_MODE 0x3C -#define CSR1 0x40 -#define RETRY_WAIT_CNT 0x44 -#define INT_CSR 0x48 -#define EVEN_FLD_MASK 0x4C -#define ODD_FLD_MASK 0x50 -#define MASK_LENGTH 0x54 -#define FIFO_FLAG_CNT 0x58 -#define IIC_CLK_DUR 0x5C -#define IIC_CSR1 0x60 -#define IIC_CSR2 0x64 - -/* DT3155 Internal Registers indexes (i2c/IIC mapped) */ -#define CSR2 0x10 -#define EVEN_CSR 0x11 -#define ODD_CSR 0x12 -#define CONFIG 0x13 -#define DT_ID 0x1F -#define X_CLIP_START 0x20 -#define Y_CLIP_START 0x22 -#define X_CLIP_END 0x24 -#define Y_CLIP_END 0x26 -#define AD_ADDR 0x30 -#define AD_LUT 0x31 -#define AD_CMD 0x32 -#define DIG_OUT 0x40 -#define PM_LUT_ADDR 0x50 -#define PM_LUT_DATA 0x51 - -/* AD command register values */ -#define AD_CMD_REG 0x00 -#define AD_POS_REF 0x01 -#define AD_NEG_REF 0x02 - -/* CSR1 bit masks */ -#define CRPT_DIS 0x00004000 -#define FLD_CRPT_ODD 0x00000200 -#define FLD_CRPT_EVEN 0x00000100 -#define FIFO_EN 0x00000080 -#define SRST 0x00000040 -#define FLD_DN_ODD 0x00000020 -#define FLD_DN_EVEN 0x00000010 -/* These should not be used. - * Use CAP_CONT_ODD/EVEN instead -#define CAP_SNGL_ODD 0x00000008 -#define CAP_SNGL_EVEN 0x00000004 -*/ -#define CAP_CONT_ODD 0x00000002 -#define CAP_CONT_EVEN 0x00000001 - -/* INT_CSR bit masks */ -#define FLD_START_EN 0x00000400 -#define FLD_END_ODD_EN 0x00000200 -#define FLD_END_EVEN_EN 0x00000100 -#define FLD_START 0x00000004 -#define FLD_END_ODD 0x00000002 -#define FLD_END_EVEN 0x00000001 - -/* IIC_CSR1 bit masks */ -#define DIRECT_ABORT 0x00000200 - -/* IIC_CSR2 bit masks */ -#define NEW_CYCLE 0x01000000 -#define DIR_RD 0x00010000 -#define IIC_READ 0x01010000 -#define IIC_WRITE 0x01000000 - -/* CSR2 bit masks */ -#define DISP_PASS 0x40 -#define BUSY_ODD 0x20 -#define BUSY_EVEN 0x10 -#define SYNC_PRESENT 0x08 -#define VT_50HZ 0x04 -#define SYNC_SNTL 0x02 -#define CHROM_FILT 0x01 -#define VT_60HZ 0x00 - -/* CSR_EVEN/ODD bit masks */ -#define CSR_ERROR 0x04 -#define CSR_SNGL 0x02 -#define CSR_DONE 0x01 - -/* CONFIG bit masks */ -#define PM_LUT_PGM 0x80 -#define PM_LUT_SEL 0x40 -#define CLIP_EN 0x20 -#define HSCALE_EN 0x10 -#define EXT_TRIG_UP 0x0C -#define EXT_TRIG_DOWN 0x04 -#define ACQ_MODE_NEXT 0x02 -#define ACQ_MODE_ODD 0x01 -#define ACQ_MODE_EVEN 0x00 - -/* AD_CMD bit masks */ -#define VIDEO_CNL_1 0x00 -#define VIDEO_CNL_2 0x40 -#define VIDEO_CNL_3 0x80 -#define VIDEO_CNL_4 0xC0 -#define SYNC_CNL_1 0x00 -#define SYNC_CNL_2 0x10 -#define SYNC_CNL_3 0x20 -#define SYNC_CNL_4 0x30 -#define SYNC_LVL_1 0x00 -#define SYNC_LVL_2 0x04 -#define SYNC_LVL_3 0x08 -#define SYNC_LVL_4 0x0C - -/* DT3155 identificator */ -#define DT3155_ID 0x20 - -#ifdef CONFIG_DT3155_CCIR -#define DMA_STRIDE 768 -#else -#define DMA_STRIDE 640 -#endif - -/** - * struct dt3155_stats - statistics structure - * - * @free_bufs_empty: no free image buffers - * @corrupted_fields: corrupted fields - * @dma_map_failed: dma mapping failed - * @start_before_end: new started before old ended - */ -struct dt3155_stats { - int free_bufs_empty; - int corrupted_fields; - int dma_map_failed; - int start_before_end; -}; - -/* per board private data structure */ -/** - * struct dt3155_priv - private data structure - * - * @vdev: video_device structure - * @pdev: pointer to pci_dev structure - * @q pointer to vb2_queue structure - * @curr_buf: pointer to curren buffer - * @mux: mutex to protect the instance - * @dmaq queue for dma buffers - * @lock spinlock for dma queue - * @field_count fields counter - * @stats: statistics structure - * @users open count - * @regs: local copy of mmio base register - * @csr2: local copy of csr2 register - * @config: local copy of config register - */ -struct dt3155_priv { - struct video_device vdev; - struct pci_dev *pdev; - struct vb2_queue *q; - struct vb2_buffer *curr_buf; - struct mutex mux; - struct list_head dmaq; - spinlock_t lock; - unsigned int field_count; - struct dt3155_stats stats; - void __iomem *regs; - int users; - u8 csr2, config; -}; - -#endif /* __KERNEL__ */ - -#endif /* _DT3155_H_ */ diff --git a/kernel/drivers/staging/media/lirc/lirc_imon.c b/kernel/drivers/staging/media/lirc/lirc_imon.c index 335b98a54..534b8103a 100644 --- a/kernel/drivers/staging/media/lirc/lirc_imon.c +++ b/kernel/drivers/staging/media/lirc/lirc_imon.c @@ -693,10 +693,9 @@ static int imon_probe(struct usb_interface *interface, int ifnum; int lirc_minor = 0; int num_endpts; - int retval = 0; + int retval = -ENOMEM; int display_ep_found = 0; int ir_ep_found = 0; - int alloc_status = 0; int vfd_proto_6p = 0; struct imon_context *context = NULL; int i; @@ -706,10 +705,8 @@ static int imon_probe(struct usb_interface *interface, mutex_lock(&driver_lock); context = kzalloc(sizeof(struct imon_context), GFP_KERNEL); - if (!context) { - alloc_status = 1; - goto alloc_status_switch; - } + if (!context) + goto driver_unlock; /* * Try to auto-detect the type of display if the user hasn't set @@ -742,7 +739,7 @@ static int imon_probe(struct usb_interface *interface, ep = &iface_desc->endpoint[i].desc; ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK; - ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; + ep_type = usb_endpoint_type(ep); if (!ir_ep_found && ep_dir == USB_DIR_IN && @@ -775,8 +772,7 @@ static int imon_probe(struct usb_interface *interface, dev_err(dev, "%s: no valid input (IR) endpoint found.\n", __func__); retval = -ENODEV; - alloc_status = 2; - goto alloc_status_switch; + goto free_context; } /* Determine if display requires 6 packets */ @@ -789,32 +785,27 @@ static int imon_probe(struct usb_interface *interface, } driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL); - if (!driver) { - alloc_status = 2; - goto alloc_status_switch; - } + if (!driver) + goto free_context; + rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL); - if (!rbuf) { - alloc_status = 3; - goto alloc_status_switch; - } + if (!rbuf) + goto free_driver; + if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) { dev_err(dev, "%s: lirc_buffer_init failed\n", __func__); - alloc_status = 4; - goto alloc_status_switch; + goto free_rbuf; } rx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!rx_urb) { dev_err(dev, "%s: usb_alloc_urb failed for IR urb\n", __func__); - alloc_status = 5; - goto alloc_status_switch; + goto free_lirc_buf; } tx_urb = usb_alloc_urb(0, GFP_KERNEL); if (!tx_urb) { dev_err(dev, "%s: usb_alloc_urb failed for display urb\n", __func__); - alloc_status = 6; - goto alloc_status_switch; + goto free_rx_urb; } mutex_init(&context->ctx_lock); @@ -840,11 +831,11 @@ static int imon_probe(struct usb_interface *interface, lirc_minor = lirc_register_driver(driver); if (lirc_minor < 0) { dev_err(dev, "%s: lirc_register_driver failed\n", __func__); - alloc_status = 7; - goto unlock; - } else - dev_info(dev, "Registered iMON driver (lirc minor: %d)\n", - lirc_minor); + goto free_tx_urb; + } + + dev_info(dev, "Registered iMON driver (lirc minor: %d)\n", + lirc_minor); /* Needed while unregistering! */ driver->minor = lirc_minor; @@ -872,11 +863,9 @@ static int imon_probe(struct usb_interface *interface, context->rx_endpoint->bInterval); retval = usb_submit_urb(context->rx_urb, GFP_KERNEL); - if (retval) { dev_err(dev, "usb_submit_urb failed for intf0 (%d)\n", retval); - alloc_status = 8; - goto unlock; + goto unregister_lirc; } usb_set_intfdata(interface, context); @@ -895,39 +884,31 @@ static int imon_probe(struct usb_interface *interface, dev_info(dev, "iMON device (%04x:%04x, intf%d) on usb<%d:%d> initialized\n", vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum); -unlock: - mutex_unlock(&context->ctx_lock); -alloc_status_switch: - - switch (alloc_status) { - case 8: - lirc_unregister_driver(driver->minor); - case 7: - usb_free_urb(tx_urb); - case 6: - usb_free_urb(rx_urb); - /* fall-through */ - case 5: - if (rbuf) - lirc_buffer_free(rbuf); - /* fall-through */ - case 4: - kfree(rbuf); - /* fall-through */ - case 3: - kfree(driver); - /* fall-through */ - case 2: - kfree(context); - context = NULL; - case 1: - if (retval != -ENODEV) - retval = -ENOMEM; - break; - case 0: - retval = 0; - } + /* Everything went fine. Just unlock and return retval (with is 0) */ + goto driver_unlock; + +unregister_lirc: + lirc_unregister_driver(driver->minor); + +free_tx_urb: + usb_free_urb(tx_urb); + +free_rx_urb: + usb_free_urb(rx_urb); + +free_lirc_buf: + lirc_buffer_free(rbuf); + +free_rbuf: + kfree(rbuf); + +free_driver: + kfree(driver); +free_context: + kfree(context); + context = NULL; +driver_unlock: mutex_unlock(&driver_lock); return retval; diff --git a/kernel/drivers/staging/media/lirc/lirc_sasem.c b/kernel/drivers/staging/media/lirc/lirc_sasem.c index 9e5674341..f2dca69c2 100644 --- a/kernel/drivers/staging/media/lirc/lirc_sasem.c +++ b/kernel/drivers/staging/media/lirc/lirc_sasem.c @@ -181,10 +181,10 @@ static void deregister_from_lirc(struct sasem_context *context) if (retval) dev_err(&context->dev->dev, "%s: unable to deregister from lirc (%d)\n", - __func__, retval); + __func__, retval); else dev_info(&context->dev->dev, - "Deregistered Sasem driver (minor:%d)\n", minor); + "Deregistered Sasem driver (minor:%d)\n", minor); } @@ -244,7 +244,7 @@ exit: */ static long vfd_ioctl(struct file *file, unsigned cmd, unsigned long arg) { - struct sasem_context *context = NULL; + struct sasem_context *context; context = (struct sasem_context *) file->private_data; @@ -697,16 +697,11 @@ static int sasem_probe(struct usb_interface *interface, for (i = 0; i < num_endpoints && !(ir_ep_found && vfd_ep_found); ++i) { struct usb_endpoint_descriptor *ep; - int ep_dir; - int ep_type; ep = &iface_desc->endpoint [i].desc; - ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK; - ep_type = ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; if (!ir_ep_found && - ep_dir == USB_DIR_IN && - ep_type == USB_ENDPOINT_XFER_INT) { + usb_endpoint_is_int_in(ep)) { rx_endpoint = ep; ir_ep_found = 1; @@ -715,8 +710,7 @@ static int sasem_probe(struct usb_interface *interface, "%s: found IR endpoint\n", __func__); } else if (!vfd_ep_found && - ep_dir == USB_DIR_OUT && - ep_type == USB_ENDPOINT_XFER_INT) { + usb_endpoint_is_int_out(ep)) { tx_endpoint = ep; vfd_ep_found = 1; diff --git a/kernel/drivers/staging/media/lirc/lirc_serial.c b/kernel/drivers/staging/media/lirc/lirc_serial.c index dc7984455..64a7b2fc5 100644 --- a/kernel/drivers/staging/media/lirc/lirc_serial.c +++ b/kernel/drivers/staging/media/lirc/lirc_serial.c @@ -109,17 +109,9 @@ static bool iommap; static int ioshift; static bool softcarrier = true; static bool share_irq; -static bool debug; static int sense = -1; /* -1 = auto, 0 = active high, 1 = active low */ static bool txsense; /* 0 = active high, 1 = active low */ -#define dprintk(fmt, args...) \ - do { \ - if (debug) \ - printk(KERN_DEBUG LIRC_DRIVER_NAME ": " \ - fmt, ## args); \ - } while (0) - /* forward declarations */ static long send_pulse_irdeo(unsigned long length); static long send_pulse_homebrew(unsigned long length); @@ -327,9 +319,6 @@ static void safe_udelay(unsigned long usecs) * time */ -/* So send_pulse can quickly convert microseconds to clocks */ -static unsigned long conv_us_to_clocks; - static int init_timing_params(unsigned int new_duty_cycle, unsigned int new_freq) { @@ -344,7 +333,6 @@ static int init_timing_params(unsigned int new_duty_cycle, /* How many clocks in a microsecond?, avoiding long long divide */ work = loops_per_sec; work *= 4295; /* 4295 = 2^32 / 1e6 */ - conv_us_to_clocks = work >> 32; /* * Carrier period in clocks, approach good up to 32GHz clock, @@ -356,11 +344,9 @@ static int init_timing_params(unsigned int new_duty_cycle, /* Derive pulse and space from the period */ pulse_width = period * duty_cycle / 100; space_width = period - pulse_width; - dprintk("in init_timing_params, freq=%d, duty_cycle=%d, " - "clk/jiffy=%ld, pulse=%ld, space=%ld, " - "conv_us_to_clocks=%ld\n", - freq, duty_cycle, __this_cpu_read(cpu_info.loops_per_jiffy), - pulse_width, space_width, conv_us_to_clocks); + pr_debug("in init_timing_params, freq=%d, duty_cycle=%d, clk/jiffy=%ld, pulse=%ld, space=%ld, conv_us_to_clocks=%ld\n", + freq, duty_cycle, __this_cpu_read(cpu_info.loops_per_jiffy), + pulse_width, space_width, conv_us_to_clocks); return 0; } #else /* ! USE_RDTSC */ @@ -382,8 +368,8 @@ static int init_timing_params(unsigned int new_duty_cycle, period = 256 * 1000000L / freq; pulse_width = period * duty_cycle / 100; space_width = period - pulse_width; - dprintk("in init_timing_params, freq=%d pulse=%ld, space=%ld\n", - freq, pulse_width, space_width); + pr_debug("in init_timing_params, freq=%d pulse=%ld, space=%ld\n", + freq, pulse_width, space_width); return 0; } #endif /* USE_RDTSC */ @@ -431,63 +417,14 @@ static long send_pulse_irdeo(unsigned long length) return ret; } -#ifdef USE_RDTSC -/* Version that uses Pentium rdtsc instruction to measure clocks */ - -/* - * This version does sub-microsecond timing using rdtsc instruction, - * and does away with the fudged LIRC_SERIAL_TRANSMITTER_LATENCY - * Implicitly i586 architecture... - Steve - */ - -static long send_pulse_homebrew_softcarrier(unsigned long length) -{ - int flag; - unsigned long target, start, now; - - /* Get going quick as we can */ - rdtscl(start); - on(); - /* Convert length from microseconds to clocks */ - length *= conv_us_to_clocks; - /* And loop till time is up - flipping at right intervals */ - now = start; - target = pulse_width; - flag = 1; - /* - * FIXME: This looks like a hard busy wait, without even an occasional, - * polite, cpu_relax() call. There's got to be a better way? - * - * The i2c code has the result of a lot of bit-banging work, I wonder if - * there's something there which could be helpful here. - */ - while ((now - start) < length) { - /* Delay till flip time */ - do { - rdtscl(now); - } while ((now - start) < target); - - /* flip */ - if (flag) { - rdtscl(now); - off(); - target += space_width; - } else { - rdtscl(now); on(); - target += pulse_width; - } - flag = !flag; - } - rdtscl(now); - return ((now - start) - length) / conv_us_to_clocks; -} -#else /* ! USE_RDTSC */ /* Version using udelay() */ /* * here we use fixed point arithmetic, with 8 * fractional bits. that gets us within 0.1% or so of the right average * frequency, albeit with some jitter in pulse length - Steve + * + * This should use ndelay instead. */ /* To match 8 fractional bits used for pulse/space length */ @@ -520,7 +457,6 @@ static long send_pulse_homebrew_softcarrier(unsigned long length) } return (actual-length) >> 8; } -#endif /* USE_RDTSC */ static long send_pulse_homebrew(unsigned long length) { @@ -555,7 +491,7 @@ static void rbwrite(int l) { if (lirc_buffer_full(&rbuf)) { /* no new signals will be accepted */ - dprintk("Buffer overrun\n"); + pr_debug("Buffer overrun\n"); return; } lirc_buffer_write(&rbuf, (void *)&l); @@ -845,7 +781,7 @@ static int lirc_serial_probe(struct platform_device *dev) dev_info(&dev->dev, "Manually using active %s receiver\n", sense ? "low" : "high"); - dprintk("Interrupt %d, port %04x obtained\n", irq, io); + dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io); return 0; } @@ -950,7 +886,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) return -ENOIOCTLCMD; case LIRC_SET_SEND_DUTY_CYCLE: - dprintk("SET_SEND_DUTY_CYCLE\n"); + pr_debug("SET_SEND_DUTY_CYCLE\n"); if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE)) return -ENOIOCTLCMD; @@ -962,7 +898,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) return init_timing_params(value, freq); case LIRC_SET_SEND_CARRIER: - dprintk("SET_SEND_CARRIER\n"); + pr_debug("SET_SEND_CARRIER\n"); if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER)) return -ENOIOCTLCMD; @@ -1157,7 +1093,7 @@ static void __exit lirc_serial_exit_module(void) { lirc_unregister_driver(driver.minor); lirc_serial_exit(); - dprintk("cleaned up module\n"); + pr_debug("cleaned up module\n"); } @@ -1208,6 +1144,3 @@ MODULE_PARM_DESC(txsense, "Sense of transmitter circuit" module_param(softcarrier, bool, S_IRUGO); MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)"); - -module_param(debug, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "Enable debugging messages"); diff --git a/kernel/drivers/staging/media/lirc/lirc_sir.c b/kernel/drivers/staging/media/lirc/lirc_sir.c index 29087f66e..4f326e97a 100644 --- a/kernel/drivers/staging/media/lirc/lirc_sir.c +++ b/kernel/drivers/staging/media/lirc/lirc_sir.c @@ -44,7 +44,7 @@ #include <linux/ioport.h> #include <linux/kernel.h> #include <linux/serial_reg.h> -#include <linux/time.h> +#include <linux/ktime.h> #include <linux/string.h> #include <linux/types.h> #include <linux/wait.h> @@ -127,9 +127,9 @@ static int threshold = 3; static DEFINE_SPINLOCK(timer_lock); static struct timer_list timerlist; /* time of last signal change detected */ -static struct timeval last_tv = {0, 0}; +static ktime_t last; /* time of last UART data ready interrupt */ -static struct timeval last_intr_tv = {0, 0}; +static ktime_t last_intr_time; static int last_value; static DECLARE_WAIT_QUEUE_HEAD(lirc_read_queue); @@ -400,20 +400,6 @@ static void drop_chrdev(void) } /* SECTION: Hardware */ -static long delta(struct timeval *tv1, struct timeval *tv2) -{ - unsigned long deltv; - - deltv = tv2->tv_sec - tv1->tv_sec; - if (deltv > 15) - deltv = 0xFFFFFF; - else - deltv = deltv*1000000 + - tv2->tv_usec - - tv1->tv_usec; - return deltv; -} - static void sir_timeout(unsigned long data) { /* @@ -432,12 +418,14 @@ static void sir_timeout(unsigned long data) /* clear unread bits in UART and restart */ outb(UART_FCR_CLEAR_RCVR, io + UART_FCR); /* determine 'virtual' pulse end: */ - pulse_end = delta(&last_tv, &last_intr_tv); + pulse_end = min_t(unsigned long, + ktime_us_delta(last, last_intr_time), + PULSE_MASK); dev_dbg(driver.dev, "timeout add %d for %lu usec\n", last_value, pulse_end); add_read_queue(last_value, pulse_end); last_value = 0; - last_tv = last_intr_tv; + last = last_intr_time; } spin_unlock_irqrestore(&timer_lock, flags); } @@ -445,9 +433,9 @@ static void sir_timeout(unsigned long data) static irqreturn_t sir_interrupt(int irq, void *dev_id) { unsigned char data; - struct timeval curr_tv; - static unsigned long deltv; - unsigned long deltintrtv; + ktime_t curr_time; + static unsigned long delt; + unsigned long deltintr; unsigned long flags; int iir, lsr; @@ -471,49 +459,46 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id) do { del_timer(&timerlist); data = inb(io + UART_RX); - do_gettimeofday(&curr_tv); - deltv = delta(&last_tv, &curr_tv); - deltintrtv = delta(&last_intr_tv, &curr_tv); + curr_time = ktime_get(); + delt = min_t(unsigned long, + ktime_us_delta(last, curr_time), + PULSE_MASK); + deltintr = min_t(unsigned long, + ktime_us_delta(last_intr_time, + curr_time), + PULSE_MASK); dev_dbg(driver.dev, "t %lu, d %d\n", - deltintrtv, (int)data); + deltintr, (int)data); /* * if nothing came in last X cycles, * it was gap */ - if (deltintrtv > TIME_CONST * threshold) { + if (deltintr > TIME_CONST * threshold) { if (last_value) { dev_dbg(driver.dev, "GAP\n"); /* simulate signal change */ add_read_queue(last_value, - deltv - - deltintrtv); + delt - + deltintr); last_value = 0; - last_tv.tv_sec = - last_intr_tv.tv_sec; - last_tv.tv_usec = - last_intr_tv.tv_usec; - deltv = deltintrtv; + last = last_intr_time; + delt = deltintr; } } data = 1; if (data ^ last_value) { /* - * deltintrtv > 2*TIME_CONST, remember? + * deltintr > 2*TIME_CONST, remember? * the other case is timeout */ add_read_queue(last_value, - deltv-TIME_CONST); + delt-TIME_CONST); last_value = data; - last_tv = curr_tv; - if (last_tv.tv_usec >= TIME_CONST) { - last_tv.tv_usec -= TIME_CONST; - } else { - last_tv.tv_sec--; - last_tv.tv_usec += 1000000 - - TIME_CONST; - } + last = curr_time; + last = ktime_sub_us(last, + TIME_CONST); } - last_intr_tv = curr_tv; + last_intr_time = curr_time; if (data) { /* * start timer for end of diff --git a/kernel/drivers/staging/media/lirc/lirc_zilog.c b/kernel/drivers/staging/media/lirc/lirc_zilog.c index 261e27d6b..ce3b5f230 100644 --- a/kernel/drivers/staging/media/lirc/lirc_zilog.c +++ b/kernel/drivers/staging/media/lirc/lirc_zilog.c @@ -1364,10 +1364,10 @@ static const struct i2c_device_id ir_transceiver_id[] = { { "ir_rx_z8f0811_hdpvr", ID_FLAG_HDPVR }, { } }; +MODULE_DEVICE_TABLE(i2c, ir_transceiver_id); static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "Zilog/Hauppauge i2c IR", }, .probe = ir_probe, diff --git a/kernel/drivers/staging/media/mn88472/mn88472.c b/kernel/drivers/staging/media/mn88472/mn88472.c index a4cfcf57c..cf2e96bcf 100644 --- a/kernel/drivers/staging/media/mn88472/mn88472.c +++ b/kernel/drivers/staging/media/mn88472/mn88472.c @@ -218,7 +218,7 @@ err: return ret; } -static int mn88472_read_status(struct dvb_frontend *fe, fe_status_t *status) +static int mn88472_read_status(struct dvb_frontend *fe, enum fe_status *status) { struct i2c_client *client = fe->demodulator_priv; struct mn88472_dev *dev = i2c_get_clientdata(client); @@ -344,12 +344,12 @@ static int mn88472_init(struct dvb_frontend *fe) if (ret) { dev_err(&client->dev, "parity reg read failed=%d\n", ret); - goto err; + goto firmware_release; } if (tmp & 0x10) { dev_err(&client->dev, "firmware parity check failed=0x%x\n", tmp); - goto err; + goto firmware_release; } dev_err(&client->dev, "firmware parity check succeeded=0x%x\n", tmp); @@ -561,7 +561,6 @@ MODULE_DEVICE_TABLE(i2c, mn88472_id_table); static struct i2c_driver mn88472_driver = { .driver = { - .owner = THIS_MODULE, .name = "mn88472", }, .probe = mn88472_probe, diff --git a/kernel/drivers/staging/media/mn88472/mn88472_priv.h b/kernel/drivers/staging/media/mn88472/mn88472_priv.h index 9ba8c8b38..1a0de9e46 100644 --- a/kernel/drivers/staging/media/mn88472/mn88472_priv.h +++ b/kernel/drivers/staging/media/mn88472/mn88472_priv.h @@ -29,7 +29,7 @@ struct mn88472_dev { struct regmap *regmap[3]; struct dvb_frontend fe; u16 i2c_wr_max; - fe_delivery_system_t delivery_system; + enum fe_delivery_system delivery_system; bool warm; /* FW running */ u32 xtal; int ts_mode; diff --git a/kernel/drivers/staging/media/mn88473/mn88473.c b/kernel/drivers/staging/media/mn88473/mn88473.c index 8b6736c70..a222e9993 100644 --- a/kernel/drivers/staging/media/mn88473/mn88473.c +++ b/kernel/drivers/staging/media/mn88473/mn88473.c @@ -167,7 +167,7 @@ err: return ret; } -static int mn88473_read_status(struct dvb_frontend *fe, fe_status_t *status) +static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status) { struct i2c_client *client = fe->demodulator_priv; struct mn88473_dev *dev = i2c_get_clientdata(client); @@ -507,7 +507,6 @@ MODULE_DEVICE_TABLE(i2c, mn88473_id_table); static struct i2c_driver mn88473_driver = { .driver = { - .owner = THIS_MODULE, .name = "mn88473", }, .probe = mn88473_probe, diff --git a/kernel/drivers/staging/media/mn88473/mn88473_priv.h b/kernel/drivers/staging/media/mn88473/mn88473_priv.h index ef6f01323..54beb4241 100644 --- a/kernel/drivers/staging/media/mn88473/mn88473_priv.h +++ b/kernel/drivers/staging/media/mn88473/mn88473_priv.h @@ -29,7 +29,7 @@ struct mn88473_dev { struct regmap *regmap[3]; struct dvb_frontend fe; u16 i2c_wr_max; - fe_delivery_system_t delivery_system; + enum fe_delivery_system delivery_system; bool warm; /* FW running */ u32 xtal; }; diff --git a/kernel/drivers/staging/media/omap4iss/Kconfig b/kernel/drivers/staging/media/omap4iss/Kconfig index 072dac04a..8d4e3bd1b 100644 --- a/kernel/drivers/staging/media/omap4iss/Kconfig +++ b/kernel/drivers/staging/media/omap4iss/Kconfig @@ -1,5 +1,5 @@ config VIDEO_OMAP4 - bool "OMAP 4 Camera support" + tristate "OMAP 4 Camera support" depends on VIDEO_V4L2=y && VIDEO_V4L2_SUBDEV_API && I2C=y && ARCH_OMAP4 depends on HAS_DMA select MFD_SYSCON diff --git a/kernel/drivers/staging/media/omap4iss/TODO b/kernel/drivers/staging/media/omap4iss/TODO index fcde88860..4d220ef82 100644 --- a/kernel/drivers/staging/media/omap4iss/TODO +++ b/kernel/drivers/staging/media/omap4iss/TODO @@ -1,4 +1,3 @@ -* Make the driver compile as a module * Fix FIFO/buffer overflows and underflows * Replace dummy resizer code with a real implementation * Fix checkpatch errors and warnings diff --git a/kernel/drivers/staging/media/omap4iss/iss.c b/kernel/drivers/staging/media/omap4iss/iss.c index 7ced940bd..aa76ccda5 100644 --- a/kernel/drivers/staging/media/omap4iss/iss.c +++ b/kernel/drivers/staging/media/omap4iss/iss.c @@ -151,7 +151,7 @@ int omap4iss_get_external_info(struct iss_pipeline *pipe, ctrl = v4l2_ctrl_find(pipe->external->ctrl_handler, V4L2_CID_PIXEL_RATE); - if (ctrl == NULL) { + if (!ctrl) { dev_warn(iss->dev, "no pixel rate control in subdev %s\n", pipe->external->name); return -EPIPE; @@ -422,7 +422,7 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) subdev = media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV ? media_entity_to_v4l2_subdev(entity) : NULL; - if (entity->use_count == 0 && change > 0 && subdev != NULL) { + if (entity->use_count == 0 && change > 0 && subdev) { int ret; ret = v4l2_subdev_call(subdev, core, s_power, 1); @@ -433,7 +433,7 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) entity->use_count += change; WARN_ON(entity->use_count < 0); - if (entity->use_count == 0 && change < 0 && subdev != NULL) + if (entity->use_count == 0 && change < 0 && subdev) v4l2_subdev_call(subdev, core, s_power, 0); return 0; @@ -469,8 +469,8 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change) media_entity_graph_walk_start(&graph, first); - while ((first = media_entity_graph_walk_next(&graph)) - && first != entity) + while ((first = media_entity_graph_walk_next(&graph)) && + first != entity) if (media_entity_type(first) != MEDIA_ENT_T_DEVNODE) iss_pipeline_pm_power_one(first, -change); @@ -541,7 +541,7 @@ static int iss_pipeline_link_notify(struct media_link *link, u32 flags, } if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && - (flags & MEDIA_LNK_FL_ENABLED)) { + (flags & MEDIA_LNK_FL_ENABLED)) { ret = iss_pipeline_pm_power(source, sink_use); if (ret < 0) return ret; @@ -590,7 +590,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (pad == NULL || + if (!pad || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -658,7 +658,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (pad == NULL || + if (!pad || media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) break; @@ -919,7 +919,7 @@ static int __iss_subclk_update(struct iss_device *iss) } int omap4iss_subclk_enable(struct iss_device *iss, - enum iss_subclk_resource res) + enum iss_subclk_resource res) { iss->subclk_resources |= res; @@ -927,7 +927,7 @@ int omap4iss_subclk_enable(struct iss_device *iss, } int omap4iss_subclk_disable(struct iss_device *iss, - enum iss_subclk_resource res) + enum iss_subclk_resource res) { iss->subclk_resources &= ~res; @@ -1050,7 +1050,7 @@ struct iss_device *omap4iss_get(struct iss_device *iss) { struct iss_device *__iss = iss; - if (iss == NULL) + if (!iss) return NULL; mutex_lock(&iss->iss_mutex); @@ -1065,7 +1065,7 @@ struct iss_device *omap4iss_get(struct iss_device *iss) iss_enable_interrupts(iss); out: - if (__iss != NULL) + if (__iss) iss->ref_count++; mutex_unlock(&iss->iss_mutex); @@ -1080,7 +1080,7 @@ out: */ void omap4iss_put(struct iss_device *iss) { - if (iss == NULL) + if (!iss) return; mutex_lock(&iss->iss_mutex); @@ -1137,12 +1137,12 @@ static void iss_unregister_entities(struct iss_device *iss) */ static struct v4l2_subdev * iss_register_subdev_group(struct iss_device *iss, - struct iss_subdev_i2c_board_info *board_info) + struct iss_subdev_i2c_board_info *board_info) { struct v4l2_subdev *sensor = NULL; unsigned int first; - if (board_info->board_info == NULL) + if (!board_info->board_info) return NULL; for (first = 1; board_info->board_info; ++board_info, first = 0) { @@ -1150,7 +1150,7 @@ iss_register_subdev_group(struct iss_device *iss, struct i2c_adapter *adapter; adapter = i2c_get_adapter(board_info->i2c_adapter_id); - if (adapter == NULL) { + if (!adapter) { dev_err(iss->dev, "%s: Unable to get I2C adapter %d for device %s\n", __func__, board_info->i2c_adapter_id, @@ -1160,7 +1160,7 @@ iss_register_subdev_group(struct iss_device *iss, subdev = v4l2_i2c_new_subdev_board(&iss->v4l2_dev, adapter, board_info->board_info, NULL); - if (subdev == NULL) { + if (!subdev) { dev_err(iss->dev, "Unable to register subdev %s\n", board_info->board_info->type); continue; @@ -1228,7 +1228,7 @@ static int iss_register_entities(struct iss_device *iss) unsigned int pad; sensor = iss_register_subdev_group(iss, subdevs->subdevs); - if (sensor == NULL) + if (!sensor) continue; sensor->host_priv = subdevs; @@ -1369,7 +1369,7 @@ static int iss_probe(struct platform_device *pdev) unsigned int i; int ret; - if (pdata == NULL) + if (!pdata) return -EINVAL; iss = devm_kzalloc(&pdev->dev, sizeof(*iss), GFP_KERNEL); @@ -1406,7 +1406,7 @@ static int iss_probe(struct platform_device *pdev) if (ret < 0) goto error; - if (omap4iss_get(iss) == NULL) + if (!omap4iss_get(iss)) goto error; ret = iss_reset(iss); @@ -1440,12 +1440,13 @@ static int iss_probe(struct platform_device *pdev) iss_reg_read(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_REVISION)); /* Interrupt */ - iss->irq_num = platform_get_irq(pdev, 0); - if (iss->irq_num <= 0) { + ret = platform_get_irq(pdev, 0); + if (ret <= 0) { dev_err(iss->dev, "No IRQ resource\n"); ret = -ENODEV; goto error_iss; } + iss->irq_num = ret; if (devm_request_irq(iss->dev, iss->irq_num, iss_isr, IRQF_SHARED, "OMAP4 ISS", iss)) { @@ -1489,7 +1490,7 @@ static int iss_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id omap4iss_id_table[] = { +static const struct platform_device_id omap4iss_id_table[] = { { "omap4iss", 0 }, { }, }; diff --git a/kernel/drivers/staging/media/omap4iss/iss_csi2.c b/kernel/drivers/staging/media/omap4iss/iss_csi2.c index d7ff7698a..c6e6d47ac 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_csi2.c +++ b/kernel/drivers/staging/media/omap4iss/iss_csi2.c @@ -658,7 +658,7 @@ static void csi2_isr_buffer(struct iss_csi2_device *csi2) * Let video queue operation restart engine if there is an underrun * condition. */ - if (buffer == NULL) + if (!buffer) return; csi2_set_outaddr(csi2, buffer->iss_addr); @@ -828,8 +828,10 @@ static const struct iss_video_operations csi2_issvideo_ops = { */ static struct v4l2_mbus_framefmt * -__csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, enum v4l2_subdev_format_whence which) +__csi2_get_format(struct iss_csi2_device *csi2, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad); @@ -838,8 +840,10 @@ __csi2_get_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *c } static void -csi2_try_format(struct iss_csi2_device *csi2, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, struct v4l2_mbus_framefmt *fmt, +csi2_try_format(struct iss_csi2_device *csi2, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + struct v4l2_mbus_framefmt *fmt, enum v4l2_subdev_format_whence which) { u32 pixelcode; @@ -967,14 +971,15 @@ static int csi2_enum_frame_size(struct v4l2_subdev *sd, * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, +static int csi2_get_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; fmt->format = *format; @@ -988,14 +993,15 @@ static int csi2_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config * @fmt: pointer to v4l2 subdev format structure * return -EINVAL or zero on success */ -static int csi2_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, +static int csi2_set_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __csi2_get_format(csi2, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; csi2_try_format(csi2, cfg, fmt->pad, &fmt->format, fmt->which); diff --git a/kernel/drivers/staging/media/omap4iss/iss_csi2.h b/kernel/drivers/staging/media/omap4iss/iss_csi2.h index 3b37978a3..f2f5343b4 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_csi2.h +++ b/kernel/drivers/staging/media/omap4iss/iss_csi2.h @@ -116,8 +116,8 @@ struct iss_csi2_ctrl_cfg { #define CSI2_PAD_SOURCE 1 #define CSI2_PADS_NUM 2 -#define CSI2_OUTPUT_IPIPEIF (1 << 0) -#define CSI2_OUTPUT_MEMORY (1 << 1) +#define CSI2_OUTPUT_IPIPEIF BIT(0) +#define CSI2_OUTPUT_MEMORY BIT(1) struct iss_csi2_device { struct v4l2_subdev subdev; diff --git a/kernel/drivers/staging/media/omap4iss/iss_ipipe.c b/kernel/drivers/staging/media/omap4iss/iss_ipipe.c index eaa82da30..dd0abeffd 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/kernel/drivers/staging/media/omap4iss/iss_ipipe.c @@ -24,8 +24,10 @@ #include "iss_ipipe.h" static struct v4l2_mbus_framefmt * -__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, enum v4l2_subdev_format_whence which); +__ipipe_get_format(struct iss_ipipe_device *ipipe, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + enum v4l2_subdev_format_whence which); static const unsigned int ipipe_fmts[] = { MEDIA_BUS_FMT_SGRBG10_1X10, @@ -176,8 +178,10 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable) } static struct v4l2_mbus_framefmt * -__ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, enum v4l2_subdev_format_whence which) +__ipipe_get_format(struct iss_ipipe_device *ipipe, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad); @@ -193,9 +197,11 @@ __ipipe_get_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config * @fmt: Format */ static void -ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config *cfg, - unsigned int pad, struct v4l2_mbus_framefmt *fmt, - enum v4l2_subdev_format_whence which) +ipipe_try_format(struct iss_ipipe_device *ipipe, + struct v4l2_subdev_pad_config *cfg, + unsigned int pad, + struct v4l2_mbus_framefmt *fmt, + enum v4l2_subdev_format_whence which) { struct v4l2_mbus_framefmt *format; unsigned int width = fmt->width; @@ -241,8 +247,8 @@ ipipe_try_format(struct iss_ipipe_device *ipipe, struct v4l2_subdev_pad_config * * return -EINVAL or zero on success */ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) { switch (code->pad) { case IPIPE_PAD_SINK: @@ -268,8 +274,8 @@ static int ipipe_enum_mbus_code(struct v4l2_subdev *sd, } static int ipipe_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; @@ -306,14 +312,15 @@ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int ipipe_get_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; fmt->format = *format; @@ -329,14 +336,15 @@ static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_confi * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int ipipe_set_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which); @@ -345,18 +353,18 @@ static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_confi /* Propagate the format from sink to source */ if (fmt->pad == IPIPE_PAD_SINK) { format = __ipipe_get_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP, - fmt->which); + fmt->which); *format = fmt->format; ipipe_try_format(ipipe, cfg, IPIPE_PAD_SOURCE_VP, format, - fmt->which); + fmt->which); } return 0; } static int ipipe_link_validate(struct v4l2_subdev *sd, struct media_link *link, - struct v4l2_subdev_format *source_fmt, - struct v4l2_subdev_format *sink_fmt) + struct v4l2_subdev_format *source_fmt, + struct v4l2_subdev_format *sink_fmt) { /* Check if the two ends match */ if (source_fmt->format.width != sink_fmt->format.width || @@ -432,8 +440,8 @@ static const struct v4l2_subdev_internal_ops ipipe_v4l2_internal_ops = { * return -EINVAL or zero on success */ static int ipipe_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) + const struct media_pad *local, + const struct media_pad *remote, u32 flags) { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -520,7 +528,7 @@ void omap4iss_ipipe_unregister_entities(struct iss_ipipe_device *ipipe) } int omap4iss_ipipe_register_entities(struct iss_ipipe_device *ipipe, - struct v4l2_device *vdev) + struct v4l2_device *vdev) { int ret; diff --git a/kernel/drivers/staging/media/omap4iss/iss_ipipe.h b/kernel/drivers/staging/media/omap4iss/iss_ipipe.h index c22d9041f..d5b441d9c 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_ipipe.h +++ b/kernel/drivers/staging/media/omap4iss/iss_ipipe.h @@ -21,7 +21,7 @@ enum ipipe_input_entity { IPIPE_INPUT_IPIPEIF, }; -#define IPIPE_OUTPUT_VP (1 << 0) +#define IPIPE_OUTPUT_VP BIT(0) /* Sink and source IPIPE pads */ #define IPIPE_PAD_SINK 0 @@ -58,7 +58,7 @@ struct iss_ipipe_device { struct iss_device; int omap4iss_ipipe_register_entities(struct iss_ipipe_device *ipipe, - struct v4l2_device *vdev); + struct v4l2_device *vdev); void omap4iss_ipipe_unregister_entities(struct iss_ipipe_device *ipipe); int omap4iss_ipipe_init(struct iss_device *iss); diff --git a/kernel/drivers/staging/media/omap4iss/iss_ipipeif.c b/kernel/drivers/staging/media/omap4iss/iss_ipipeif.c index 530ac8426..5f9e449e7 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/kernel/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -115,7 +115,7 @@ static void ipipeif_set_outaddr(struct iss_ipipeif_device *ipipeif, u32 addr) { struct iss_device *iss = to_iss_device(ipipeif); - /* Save address splitted in Base Address H & L */ + /* Save address split in Base Address H & L */ iss_reg_write(iss, OMAP4_ISS_MEM_ISP_ISIF, ISIF_CADU, (addr >> (16 + 5)) & ISIF_CADU_MASK); iss_reg_write(iss, OMAP4_ISS_MEM_ISP_ISIF, ISIF_CADL, @@ -233,7 +233,7 @@ static void ipipeif_isr_buffer(struct iss_ipipeif_device *ipipeif) ipipeif_write_enable(ipipeif, 0); buffer = omap4iss_video_buffer_next(&ipipeif->video_out); - if (buffer == NULL) + if (!buffer) return; ipipeif_set_outaddr(ipipeif, buffer->iss_addr); @@ -446,8 +446,8 @@ ipipeif_try_format(struct iss_ipipeif_device *ipipeif, * return -EINVAL or zero on success */ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; @@ -480,8 +480,8 @@ static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd, } static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; @@ -518,14 +518,15 @@ static int ipipeif_enum_frame_size(struct v4l2_subdev *sd, * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int ipipeif_get_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; fmt->format = *format; @@ -541,14 +542,15 @@ static int ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_con * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int ipipeif_set_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which); @@ -568,7 +570,7 @@ static int ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_con fmt->which); *format = fmt->format; ipipeif_try_format(ipipeif, cfg, IPIPEIF_PAD_SOURCE_VP, format, - fmt->which); + fmt->which); } return 0; @@ -654,8 +656,8 @@ static const struct v4l2_subdev_internal_ops ipipeif_v4l2_internal_ops = { * return -EINVAL or zero on success */ static int ipipeif_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) + const struct media_pad *local, + const struct media_pad *remote, u32 flags) { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); @@ -776,7 +778,7 @@ void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif) } int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif, - struct v4l2_device *vdev) + struct v4l2_device *vdev) { int ret; diff --git a/kernel/drivers/staging/media/omap4iss/iss_ipipeif.h b/kernel/drivers/staging/media/omap4iss/iss_ipipeif.h index cbdccb982..c6bd96d96 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_ipipeif.h +++ b/kernel/drivers/staging/media/omap4iss/iss_ipipeif.h @@ -22,8 +22,8 @@ enum ipipeif_input_entity { IPIPEIF_INPUT_CSI2B }; -#define IPIPEIF_OUTPUT_MEMORY (1 << 0) -#define IPIPEIF_OUTPUT_VP (1 << 1) +#define IPIPEIF_OUTPUT_MEMORY BIT(0) +#define IPIPEIF_OUTPUT_VP BIT(1) /* Sink and source IPIPEIF pads */ #define IPIPEIF_PAD_SINK 0 @@ -80,13 +80,13 @@ struct iss_device; int omap4iss_ipipeif_init(struct iss_device *iss); void omap4iss_ipipeif_cleanup(struct iss_device *iss); int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif, - struct v4l2_device *vdev); + struct v4l2_device *vdev); void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif); int omap4iss_ipipeif_busy(struct iss_ipipeif_device *ipipeif); void omap4iss_ipipeif_isr(struct iss_ipipeif_device *ipipeif, u32 events); void omap4iss_ipipeif_restore_context(struct iss_device *iss); void omap4iss_ipipeif_max_rate(struct iss_ipipeif_device *ipipeif, - unsigned int *max_rate); + unsigned int *max_rate); #endif /* OMAP4_ISS_IPIPEIF_H */ diff --git a/kernel/drivers/staging/media/omap4iss/iss_regs.h b/kernel/drivers/staging/media/omap4iss/iss_regs.h index d2b6b6ae9..cb415e898 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_regs.h +++ b/kernel/drivers/staging/media/omap4iss/iss_regs.h @@ -22,21 +22,21 @@ #define ISS_HL_SYSCONFIG_IDLEMODE_FORCEIDLE 0x0 #define ISS_HL_SYSCONFIG_IDLEMODE_NOIDLE 0x1 #define ISS_HL_SYSCONFIG_IDLEMODE_SMARTIDLE 0x2 -#define ISS_HL_SYSCONFIG_SOFTRESET (1 << 0) +#define ISS_HL_SYSCONFIG_SOFTRESET BIT(0) #define ISS_HL_IRQSTATUS_RAW(i) (0x20 + (0x10 * (i))) #define ISS_HL_IRQSTATUS(i) (0x24 + (0x10 * (i))) #define ISS_HL_IRQENABLE_SET(i) (0x28 + (0x10 * (i))) #define ISS_HL_IRQENABLE_CLR(i) (0x2c + (0x10 * (i))) -#define ISS_HL_IRQ_HS_VS (1 << 17) -#define ISS_HL_IRQ_SIMCOP(i) (1 << (12 + (i))) -#define ISS_HL_IRQ_BTE (1 << 11) -#define ISS_HL_IRQ_CBUFF (1 << 10) -#define ISS_HL_IRQ_CCP2(i) (1 << ((i) > 3 ? 16 : 14 + (i))) -#define ISS_HL_IRQ_CSIB (1 << 5) -#define ISS_HL_IRQ_CSIA (1 << 4) -#define ISS_HL_IRQ_ISP(i) (1 << (i)) +#define ISS_HL_IRQ_HS_VS BIT(17) +#define ISS_HL_IRQ_SIMCOP(i) BIT(12 + (i)) +#define ISS_HL_IRQ_BTE BIT(11) +#define ISS_HL_IRQ_CBUFF BIT(10) +#define ISS_HL_IRQ_CCP2(i) BIT((i) > 3 ? 16 : 14 + (i)) +#define ISS_HL_IRQ_CSIB BIT(5) +#define ISS_HL_IRQ_CSIA BIT(4) +#define ISS_HL_IRQ_ISP(i) BIT(i) #define ISS_CTRL 0x80 #define ISS_CTRL_CLK_DIV_MASK (3 << 4) @@ -46,24 +46,24 @@ #define ISS_CTRL_SYNC_DETECT_VS_RAISING (3 << 0) #define ISS_CLKCTRL 0x84 -#define ISS_CLKCTRL_VPORT2_CLK (1 << 30) -#define ISS_CLKCTRL_VPORT1_CLK (1 << 29) -#define ISS_CLKCTRL_VPORT0_CLK (1 << 28) -#define ISS_CLKCTRL_CCP2 (1 << 4) -#define ISS_CLKCTRL_CSI2_B (1 << 3) -#define ISS_CLKCTRL_CSI2_A (1 << 2) -#define ISS_CLKCTRL_ISP (1 << 1) -#define ISS_CLKCTRL_SIMCOP (1 << 0) +#define ISS_CLKCTRL_VPORT2_CLK BIT(30) +#define ISS_CLKCTRL_VPORT1_CLK BIT(29) +#define ISS_CLKCTRL_VPORT0_CLK BIT(28) +#define ISS_CLKCTRL_CCP2 BIT(4) +#define ISS_CLKCTRL_CSI2_B BIT(3) +#define ISS_CLKCTRL_CSI2_A BIT(2) +#define ISS_CLKCTRL_ISP BIT(1) +#define ISS_CLKCTRL_SIMCOP BIT(0) #define ISS_CLKSTAT 0x88 -#define ISS_CLKSTAT_VPORT2_CLK (1 << 30) -#define ISS_CLKSTAT_VPORT1_CLK (1 << 29) -#define ISS_CLKSTAT_VPORT0_CLK (1 << 28) -#define ISS_CLKSTAT_CCP2 (1 << 4) -#define ISS_CLKSTAT_CSI2_B (1 << 3) -#define ISS_CLKSTAT_CSI2_A (1 << 2) -#define ISS_CLKSTAT_ISP (1 << 1) -#define ISS_CLKSTAT_SIMCOP (1 << 0) +#define ISS_CLKSTAT_VPORT2_CLK BIT(30) +#define ISS_CLKSTAT_VPORT1_CLK BIT(29) +#define ISS_CLKSTAT_VPORT0_CLK BIT(28) +#define ISS_CLKSTAT_CCP2 BIT(4) +#define ISS_CLKSTAT_CSI2_B BIT(3) +#define ISS_CLKSTAT_CSI2_A BIT(2) +#define ISS_CLKSTAT_ISP BIT(1) +#define ISS_CLKSTAT_SIMCOP BIT(0) #define ISS_PM_STATUS 0x8c #define ISS_PM_STATUS_CBUFF_PM_MASK (3 << 12) @@ -75,15 +75,15 @@ #define ISS_PM_STATUS_CSI2_A_PM_MASK (3 << 0) #define REGISTER0 0x0 -#define REGISTER0_HSCLOCKCONFIG (1 << 24) +#define REGISTER0_HSCLOCKCONFIG BIT(24) #define REGISTER0_THS_TERM_MASK (0xff << 8) #define REGISTER0_THS_TERM_SHIFT 8 #define REGISTER0_THS_SETTLE_MASK (0xff << 0) #define REGISTER0_THS_SETTLE_SHIFT 0 #define REGISTER1 0x4 -#define REGISTER1_RESET_DONE_CTRLCLK (1 << 29) -#define REGISTER1_CLOCK_MISS_DETECTOR_STATUS (1 << 25) +#define REGISTER1_RESET_DONE_CTRLCLK BIT(29) +#define REGISTER1_CLOCK_MISS_DETECTOR_STATUS BIT(25) #define REGISTER1_TCLK_TERM_MASK (0x3f << 18) #define REGISTER1_TCLK_TERM_SHIFT 18 #define REGISTER1_DPHY_HS_SYNC_PATTERN_SHIFT 10 @@ -103,20 +103,20 @@ #define CSI2_SYSCONFIG_AUTO_IDLE (1 << 0) #define CSI2_SYSSTATUS 0x14 -#define CSI2_SYSSTATUS_RESET_DONE (1 << 0) +#define CSI2_SYSSTATUS_RESET_DONE BIT(0) #define CSI2_IRQSTATUS 0x18 #define CSI2_IRQENABLE 0x1c /* Shared bits across CSI2_IRQENABLE and IRQSTATUS */ -#define CSI2_IRQ_OCP_ERR (1 << 14) -#define CSI2_IRQ_SHORT_PACKET (1 << 13) -#define CSI2_IRQ_ECC_CORRECTION (1 << 12) -#define CSI2_IRQ_ECC_NO_CORRECTION (1 << 11) -#define CSI2_IRQ_COMPLEXIO_ERR (1 << 9) -#define CSI2_IRQ_FIFO_OVF (1 << 8) -#define CSI2_IRQ_CONTEXT0 (1 << 0) +#define CSI2_IRQ_OCP_ERR BIT(14) +#define CSI2_IRQ_SHORT_PACKET BIT(13) +#define CSI2_IRQ_ECC_CORRECTION BIT(12) +#define CSI2_IRQ_ECC_NO_CORRECTION BIT(11) +#define CSI2_IRQ_COMPLEXIO_ERR BIT(9) +#define CSI2_IRQ_FIFO_OVF BIT(8) +#define CSI2_IRQ_CONTEXT0 BIT(0) #define CSI2_CTRL 0x40 #define CSI2_CTRL_MFLAG_LEVH_MASK (7 << 20) @@ -164,55 +164,55 @@ #define CSI2_COMPLEXIO_IRQENABLE 0x60 /* Shared bits across CSI2_COMPLEXIO_IRQENABLE and IRQSTATUS */ -#define CSI2_COMPLEXIO_IRQ_STATEALLULPMEXIT (1 << 26) -#define CSI2_COMPLEXIO_IRQ_STATEALLULPMENTER (1 << 25) -#define CSI2_COMPLEXIO_IRQ_STATEULPM5 (1 << 24) -#define CSI2_COMPLEXIO_IRQ_STATEULPM4 (1 << 23) -#define CSI2_COMPLEXIO_IRQ_STATEULPM3 (1 << 22) -#define CSI2_COMPLEXIO_IRQ_STATEULPM2 (1 << 21) -#define CSI2_COMPLEXIO_IRQ_STATEULPM1 (1 << 20) -#define CSI2_COMPLEXIO_IRQ_ERRCONTROL5 (1 << 19) -#define CSI2_COMPLEXIO_IRQ_ERRCONTROL4 (1 << 18) -#define CSI2_COMPLEXIO_IRQ_ERRCONTROL3 (1 << 17) -#define CSI2_COMPLEXIO_IRQ_ERRCONTROL2 (1 << 16) -#define CSI2_COMPLEXIO_IRQ_ERRCONTROL1 (1 << 15) -#define CSI2_COMPLEXIO_IRQ_ERRESC5 (1 << 14) -#define CSI2_COMPLEXIO_IRQ_ERRESC4 (1 << 13) -#define CSI2_COMPLEXIO_IRQ_ERRESC3 (1 << 12) -#define CSI2_COMPLEXIO_IRQ_ERRESC2 (1 << 11) -#define CSI2_COMPLEXIO_IRQ_ERRESC1 (1 << 10) -#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS5 (1 << 9) -#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS4 (1 << 8) -#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS3 (1 << 7) -#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS2 (1 << 6) -#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS1 (1 << 5) -#define CSI2_COMPLEXIO_IRQ_ERRSOTHS5 (1 << 4) -#define CSI2_COMPLEXIO_IRQ_ERRSOTHS4 (1 << 3) -#define CSI2_COMPLEXIO_IRQ_ERRSOTHS3 (1 << 2) -#define CSI2_COMPLEXIO_IRQ_ERRSOTHS2 (1 << 1) -#define CSI2_COMPLEXIO_IRQ_ERRSOTHS1 (1 << 0) +#define CSI2_COMPLEXIO_IRQ_STATEALLULPMEXIT BIT(26) +#define CSI2_COMPLEXIO_IRQ_STATEALLULPMENTER BIT(25) +#define CSI2_COMPLEXIO_IRQ_STATEULPM5 BIT(24) +#define CSI2_COMPLEXIO_IRQ_STATEULPM4 BIT(23) +#define CSI2_COMPLEXIO_IRQ_STATEULPM3 BIT(22) +#define CSI2_COMPLEXIO_IRQ_STATEULPM2 BIT(21) +#define CSI2_COMPLEXIO_IRQ_STATEULPM1 BIT(20) +#define CSI2_COMPLEXIO_IRQ_ERRCONTROL5 BIT(19) +#define CSI2_COMPLEXIO_IRQ_ERRCONTROL4 BIT(18) +#define CSI2_COMPLEXIO_IRQ_ERRCONTROL3 BIT(17) +#define CSI2_COMPLEXIO_IRQ_ERRCONTROL2 BIT(16) +#define CSI2_COMPLEXIO_IRQ_ERRCONTROL1 BIT(15) +#define CSI2_COMPLEXIO_IRQ_ERRESC5 BIT(14) +#define CSI2_COMPLEXIO_IRQ_ERRESC4 BIT(13) +#define CSI2_COMPLEXIO_IRQ_ERRESC3 BIT(12) +#define CSI2_COMPLEXIO_IRQ_ERRESC2 BIT(11) +#define CSI2_COMPLEXIO_IRQ_ERRESC1 BIT(10) +#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS5 BIT(9) +#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS4 BIT(8) +#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS3 BIT(7) +#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS2 BIT(6) +#define CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS1 BIT(5) +#define CSI2_COMPLEXIO_IRQ_ERRSOTHS5 BIT(4) +#define CSI2_COMPLEXIO_IRQ_ERRSOTHS4 BIT(3) +#define CSI2_COMPLEXIO_IRQ_ERRSOTHS3 BIT(2) +#define CSI2_COMPLEXIO_IRQ_ERRSOTHS2 BIT(1) +#define CSI2_COMPLEXIO_IRQ_ERRSOTHS1 BIT(0) #define CSI2_DBG_P 0x68 #define CSI2_TIMING 0x6c -#define CSI2_TIMING_FORCE_RX_MODE_IO1 (1 << 15) -#define CSI2_TIMING_STOP_STATE_X16_IO1 (1 << 14) -#define CSI2_TIMING_STOP_STATE_X4_IO1 (1 << 13) +#define CSI2_TIMING_FORCE_RX_MODE_IO1 BIT(15) +#define CSI2_TIMING_STOP_STATE_X16_IO1 BIT(14) +#define CSI2_TIMING_STOP_STATE_X4_IO1 BIT(13) #define CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK (0x1fff << 0) #define CSI2_TIMING_STOP_STATE_COUNTER_IO1_SHIFT 0 #define CSI2_CTX_CTRL1(i) (0x70 + (0x20 * i)) -#define CSI2_CTX_CTRL1_GENERIC (1 << 30) +#define CSI2_CTX_CTRL1_GENERIC BIT(30) #define CSI2_CTX_CTRL1_TRANSCODE (0xf << 24) #define CSI2_CTX_CTRL1_FEC_NUMBER_MASK (0xff << 16) #define CSI2_CTX_CTRL1_COUNT_MASK (0xff << 8) #define CSI2_CTX_CTRL1_COUNT_SHIFT 8 -#define CSI2_CTX_CTRL1_EOF_EN (1 << 7) -#define CSI2_CTX_CTRL1_EOL_EN (1 << 6) -#define CSI2_CTX_CTRL1_CS_EN (1 << 5) -#define CSI2_CTX_CTRL1_COUNT_UNLOCK (1 << 4) -#define CSI2_CTX_CTRL1_PING_PONG (1 << 3) -#define CSI2_CTX_CTRL1_CTX_EN (1 << 0) +#define CSI2_CTX_CTRL1_EOF_EN BIT(7) +#define CSI2_CTX_CTRL1_EOL_EN BIT(6) +#define CSI2_CTX_CTRL1_CS_EN BIT(5) +#define CSI2_CTX_CTRL1_COUNT_UNLOCK BIT(4) +#define CSI2_CTX_CTRL1_PING_PONG BIT(3) +#define CSI2_CTX_CTRL1_CTX_EN BIT(0) #define CSI2_CTX_CTRL2(i) (0x74 + (0x20 * i)) #define CSI2_CTX_CTRL2_FRAME_MASK (0xffff << 16) @@ -244,14 +244,14 @@ (0x3fff << CSI2_CTX_CTRL3_ALPHA_SHIFT) /* Shared bits across CSI2_CTX_IRQENABLE and IRQSTATUS */ -#define CSI2_CTX_IRQ_ECC_CORRECTION (1 << 8) -#define CSI2_CTX_IRQ_LINE_NUMBER (1 << 7) -#define CSI2_CTX_IRQ_FRAME_NUMBER (1 << 6) -#define CSI2_CTX_IRQ_CS (1 << 5) -#define CSI2_CTX_IRQ_LE (1 << 3) -#define CSI2_CTX_IRQ_LS (1 << 2) -#define CSI2_CTX_IRQ_FE (1 << 1) -#define CSI2_CTX_IRQ_FS (1 << 0) +#define CSI2_CTX_IRQ_ECC_CORRECTION BIT(8) +#define CSI2_CTX_IRQ_LINE_NUMBER BIT(7) +#define CSI2_CTX_IRQ_FRAME_NUMBER BIT(6) +#define CSI2_CTX_IRQ_CS BIT(5) +#define CSI2_CTX_IRQ_LE BIT(3) +#define CSI2_CTX_IRQ_LS BIT(2) +#define CSI2_CTX_IRQ_FE BIT(1) +#define CSI2_CTX_IRQ_FS BIT(0) /* ISS BTE */ #define BTE_CTRL (0x0030) @@ -272,49 +272,49 @@ #define ISP5_IRQENABLE_CLR(i) (0x0030 + (0x10 * (i))) /* Bits shared for ISP5_IRQ* registers */ -#define ISP5_IRQ_OCP_ERR (1 << 31) -#define ISP5_IRQ_IPIPE_INT_DPC_RNEW1 (1 << 29) -#define ISP5_IRQ_IPIPE_INT_DPC_RNEW0 (1 << 28) -#define ISP5_IRQ_IPIPE_INT_DPC_INIT (1 << 27) -#define ISP5_IRQ_IPIPE_INT_EOF (1 << 25) -#define ISP5_IRQ_H3A_INT_EOF (1 << 24) -#define ISP5_IRQ_RSZ_INT_EOF1 (1 << 23) -#define ISP5_IRQ_RSZ_INT_EOF0 (1 << 22) -#define ISP5_IRQ_RSZ_FIFO_IN_BLK_ERR (1 << 19) -#define ISP5_IRQ_RSZ_FIFO_OVF (1 << 18) -#define ISP5_IRQ_RSZ_INT_CYC_RSZB (1 << 17) -#define ISP5_IRQ_RSZ_INT_CYC_RSZA (1 << 16) -#define ISP5_IRQ_RSZ_INT_DMA (1 << 15) -#define ISP5_IRQ_RSZ_INT_LAST_PIX (1 << 14) -#define ISP5_IRQ_RSZ_INT_REG (1 << 13) -#define ISP5_IRQ_H3A_INT (1 << 12) -#define ISP5_IRQ_AF_INT (1 << 11) -#define ISP5_IRQ_AEW_INT (1 << 10) -#define ISP5_IRQ_IPIPEIF_IRQ (1 << 9) -#define ISP5_IRQ_IPIPE_INT_HST (1 << 8) -#define ISP5_IRQ_IPIPE_INT_BSC (1 << 7) -#define ISP5_IRQ_IPIPE_INT_DMA (1 << 6) -#define ISP5_IRQ_IPIPE_INT_LAST_PIX (1 << 5) -#define ISP5_IRQ_IPIPE_INT_REG (1 << 4) -#define ISP5_IRQ_ISIF_INT(i) (1 << (i)) +#define ISP5_IRQ_OCP_ERR BIT(31) +#define ISP5_IRQ_IPIPE_INT_DPC_RNEW1 BIT(29) +#define ISP5_IRQ_IPIPE_INT_DPC_RNEW0 BIT(28) +#define ISP5_IRQ_IPIPE_INT_DPC_INIT BIT(27) +#define ISP5_IRQ_IPIPE_INT_EOF BIT(25) +#define ISP5_IRQ_H3A_INT_EOF BIT(24) +#define ISP5_IRQ_RSZ_INT_EOF1 BIT(23) +#define ISP5_IRQ_RSZ_INT_EOF0 BIT(22) +#define ISP5_IRQ_RSZ_FIFO_IN_BLK_ERR BIT(19) +#define ISP5_IRQ_RSZ_FIFO_OVF BIT(18) +#define ISP5_IRQ_RSZ_INT_CYC_RSZB BIT(17) +#define ISP5_IRQ_RSZ_INT_CYC_RSZA BIT(16) +#define ISP5_IRQ_RSZ_INT_DMA BIT(15) +#define ISP5_IRQ_RSZ_INT_LAST_PIX BIT(14) +#define ISP5_IRQ_RSZ_INT_REG BIT(13) +#define ISP5_IRQ_H3A_INT BIT(12) +#define ISP5_IRQ_AF_INT BIT(11) +#define ISP5_IRQ_AEW_INT BIT(10) +#define ISP5_IRQ_IPIPEIF_IRQ BIT(9) +#define ISP5_IRQ_IPIPE_INT_HST BIT(8) +#define ISP5_IRQ_IPIPE_INT_BSC BIT(7) +#define ISP5_IRQ_IPIPE_INT_DMA BIT(6) +#define ISP5_IRQ_IPIPE_INT_LAST_PIX BIT(5) +#define ISP5_IRQ_IPIPE_INT_REG BIT(4) +#define ISP5_IRQ_ISIF_INT(i) BIT(i) #define ISP5_CTRL (0x006c) -#define ISP5_CTRL_MSTANDBY (1 << 24) -#define ISP5_CTRL_VD_PULSE_EXT (1 << 23) -#define ISP5_CTRL_MSTANDBY_WAIT (1 << 20) -#define ISP5_CTRL_BL_CLK_ENABLE (1 << 15) -#define ISP5_CTRL_ISIF_CLK_ENABLE (1 << 14) -#define ISP5_CTRL_H3A_CLK_ENABLE (1 << 13) -#define ISP5_CTRL_RSZ_CLK_ENABLE (1 << 12) -#define ISP5_CTRL_IPIPE_CLK_ENABLE (1 << 11) -#define ISP5_CTRL_IPIPEIF_CLK_ENABLE (1 << 10) -#define ISP5_CTRL_SYNC_ENABLE (1 << 9) -#define ISP5_CTRL_PSYNC_CLK_SEL (1 << 8) +#define ISP5_CTRL_MSTANDBY BIT(24) +#define ISP5_CTRL_VD_PULSE_EXT BIT(23) +#define ISP5_CTRL_MSTANDBY_WAIT BIT(20) +#define ISP5_CTRL_BL_CLK_ENABLE BIT(15) +#define ISP5_CTRL_ISIF_CLK_ENABLE BIT(14) +#define ISP5_CTRL_H3A_CLK_ENABLE BIT(13) +#define ISP5_CTRL_RSZ_CLK_ENABLE BIT(12) +#define ISP5_CTRL_IPIPE_CLK_ENABLE BIT(11) +#define ISP5_CTRL_IPIPEIF_CLK_ENABLE BIT(10) +#define ISP5_CTRL_SYNC_ENABLE BIT(9) +#define ISP5_CTRL_PSYNC_CLK_SEL BIT(8) /* ISS ISP ISIF register offsets */ #define ISIF_SYNCEN (0x0000) -#define ISIF_SYNCEN_DWEN (1 << 1) -#define ISIF_SYNCEN_SYEN (1 << 0) +#define ISIF_SYNCEN_DWEN BIT(1) +#define ISIF_SYNCEN_SYEN BIT(0) #define ISIF_MODESET (0x0004) #define ISIF_MODESET_INPMOD_MASK (3 << 12) @@ -338,7 +338,7 @@ #define ISIF_LNV_MASK (0x7fff) #define ISIF_HSIZE (0x0034) -#define ISIF_HSIZE_ADCR (1 << 12) +#define ISIF_HSIZE_ADCR BIT(12) #define ISIF_HSIZE_HSIZE_MASK (0xfff) #define ISIF_CADU (0x003c) @@ -373,7 +373,7 @@ #define ISIF_CGAMMAWD_GWDI(bpp) ((16 - (bpp)) << 1) #define ISIF_CCDCFG (0x0088) -#define ISIF_CCDCFG_Y8POS (1 << 11) +#define ISIF_CCDCFG_Y8POS BIT(11) /* ISS ISP IPIPEIF register offsets */ #define IPIPEIF_ENABLE (0x0000) @@ -391,22 +391,22 @@ #define IPIPEIF_CFG1_INPSRC2_SDRAM_YUV (3 << 2) #define IPIPEIF_CFG2 (0x0030) -#define IPIPEIF_CFG2_YUV8P (1 << 7) -#define IPIPEIF_CFG2_YUV8 (1 << 6) -#define IPIPEIF_CFG2_YUV16 (1 << 3) -#define IPIPEIF_CFG2_VDPOL (1 << 2) -#define IPIPEIF_CFG2_HDPOL (1 << 1) -#define IPIPEIF_CFG2_INTSW (1 << 0) +#define IPIPEIF_CFG2_YUV8P BIT(7) +#define IPIPEIF_CFG2_YUV8 BIT(6) +#define IPIPEIF_CFG2_YUV16 BIT(3) +#define IPIPEIF_CFG2_VDPOL BIT(2) +#define IPIPEIF_CFG2_HDPOL BIT(1) +#define IPIPEIF_CFG2_INTSW BIT(0) #define IPIPEIF_CLKDIV (0x0040) /* ISS ISP IPIPE register offsets */ #define IPIPE_SRC_EN (0x0000) -#define IPIPE_SRC_EN_EN (1 << 0) +#define IPIPE_SRC_EN_EN BIT(0) #define IPIPE_SRC_MODE (0x0004) -#define IPIPE_SRC_MODE_WRT (1 << 1) -#define IPIPE_SRC_MODE_OST (1 << 0) +#define IPIPE_SRC_MODE_WRT BIT(1) +#define IPIPE_SRC_MODE_OST BIT(0) #define IPIPE_SRC_FMT (0x0008) #define IPIPE_SRC_FMT_RAW2YUV (0 << 0) @@ -449,13 +449,13 @@ #define IPIPE_SRC_STA (0x0024) #define IPIPE_GCK_MMR (0x0028) -#define IPIPE_GCK_MMR_REG (1 << 0) +#define IPIPE_GCK_MMR_REG BIT(0) #define IPIPE_GCK_PIX (0x002c) -#define IPIPE_GCK_PIX_G3 (1 << 3) -#define IPIPE_GCK_PIX_G2 (1 << 2) -#define IPIPE_GCK_PIX_G1 (1 << 1) -#define IPIPE_GCK_PIX_G0 (1 << 0) +#define IPIPE_GCK_PIX_G3 BIT(3) +#define IPIPE_GCK_PIX_G2 BIT(2) +#define IPIPE_GCK_PIX_G1 BIT(1) +#define IPIPE_GCK_PIX_G0 BIT(0) #define IPIPE_DPC_LUT_EN (0x0034) #define IPIPE_DPC_LUT_SEL (0x0038) @@ -633,8 +633,8 @@ #define IPIPE_YUV_OFT_CR (0x02c4) #define IPIPE_YUV_PHS (0x02c8) -#define IPIPE_YUV_PHS_LPF (1 << 1) -#define IPIPE_YUV_PHS_POS (1 << 0) +#define IPIPE_YUV_PHS_LPF BIT(1) +#define IPIPE_YUV_PHS_POS BIT(0) #define IPIPE_YEE_EN (0x02d4) #define IPIPE_YEE_TYP (0x02d8) @@ -739,8 +739,8 @@ /* ISS ISP Resizer register offsets */ #define RSZ_REVISION (0x0000) #define RSZ_SYSCONFIG (0x0004) -#define RSZ_SYSCONFIG_RSZB_CLK_EN (1 << 9) -#define RSZ_SYSCONFIG_RSZA_CLK_EN (1 << 8) +#define RSZ_SYSCONFIG_RSZB_CLK_EN BIT(9) +#define RSZ_SYSCONFIG_RSZA_CLK_EN BIT(8) #define RSZ_IN_FIFO_CTRL (0x000c) #define RSZ_IN_FIFO_CTRL_THRLD_LOW_MASK (0x1ff << 16) @@ -752,18 +752,18 @@ #define RSZ_FRACDIV_MASK (0xffff) #define RSZ_SRC_EN (0x0020) -#define RSZ_SRC_EN_SRC_EN (1 << 0) +#define RSZ_SRC_EN_SRC_EN BIT(0) #define RSZ_SRC_MODE (0x0024) -#define RSZ_SRC_MODE_OST (1 << 0) -#define RSZ_SRC_MODE_WRT (1 << 1) +#define RSZ_SRC_MODE_OST BIT(0) +#define RSZ_SRC_MODE_WRT BIT(1) #define RSZ_SRC_FMT0 (0x0028) -#define RSZ_SRC_FMT0_BYPASS (1 << 1) -#define RSZ_SRC_FMT0_SEL (1 << 0) +#define RSZ_SRC_FMT0_BYPASS BIT(1) +#define RSZ_SRC_FMT0_SEL BIT(0) #define RSZ_SRC_FMT1 (0x002c) -#define RSZ_SRC_FMT1_IN420 (1 << 1) +#define RSZ_SRC_FMT1_IN420 BIT(1) #define RSZ_SRC_VPS (0x0030) #define RSZ_SRC_VSZ (0x0034) @@ -773,10 +773,10 @@ #define RSZ_DMA_RZB (0x0044) #define RSZ_DMA_STA (0x0048) #define RSZ_GCK_MMR (0x004c) -#define RSZ_GCK_MMR_MMR (1 << 0) +#define RSZ_GCK_MMR_MMR BIT(0) #define RSZ_GCK_SDR (0x0054) -#define RSZ_GCK_SDR_CORE (1 << 0) +#define RSZ_GCK_SDR_CORE BIT(0) #define RSZ_IRQ_RZA (0x0058) #define RSZ_IRQ_RZA_MASK (0x1fff) @@ -790,12 +790,12 @@ #define RSZ_YUV_C_MAX (0x006c) #define RSZ_SEQ (0x0074) -#define RSZ_SEQ_HRVB (1 << 2) -#define RSZ_SEQ_HRVA (1 << 0) +#define RSZ_SEQ_HRVB BIT(2) +#define RSZ_SEQ_HRVA BIT(0) #define RZA_EN (0x0078) #define RZA_MODE (0x007c) -#define RZA_MODE_ONE_SHOT (1 << 0) +#define RZA_MODE_ONE_SHOT BIT(0) #define RZA_420 (0x0080) #define RZA_I_VPS (0x0084) @@ -859,10 +859,10 @@ #define RZB_SDR_C_PTR_E (0x0194) /* Shared Bitmasks between RZA & RZB */ -#define RSZ_EN_EN (1 << 0) +#define RSZ_EN_EN BIT(0) -#define RSZ_420_CEN (1 << 1) -#define RSZ_420_YEN (1 << 0) +#define RSZ_420_CEN BIT(1) +#define RSZ_420_YEN BIT(0) #define RSZ_I_VPS_MASK (0x1fff) @@ -878,8 +878,8 @@ #define RSZ_V_DIF_MASK (0x3fff) -#define RSZ_V_TYP_C (1 << 1) -#define RSZ_V_TYP_Y (1 << 0) +#define RSZ_V_TYP_C BIT(1) +#define RSZ_V_TYP_Y BIT(0) #define RSZ_V_LPF_C_MASK (0x3f << 6) #define RSZ_V_LPF_C_SHIFT 6 @@ -890,14 +890,14 @@ #define RSZ_H_DIF_MASK (0x3fff) -#define RSZ_H_TYP_C (1 << 1) -#define RSZ_H_TYP_Y (1 << 0) +#define RSZ_H_TYP_C BIT(1) +#define RSZ_H_TYP_Y BIT(0) #define RSZ_H_LPF_C_MASK (0x3f << 6) #define RSZ_H_LPF_C_SHIFT 6 #define RSZ_H_LPF_Y_MASK (0x3f << 0) #define RSZ_H_LPF_Y_SHIFT 0 -#define RSZ_DWN_EN_DWN_EN (1 << 0) +#define RSZ_DWN_EN_DWN_EN BIT(0) #endif /* _OMAP4_ISS_REGS_H_ */ diff --git a/kernel/drivers/staging/media/omap4iss/iss_resizer.c b/kernel/drivers/staging/media/omap4iss/iss_resizer.c index 5f69012c4..9c8180bba 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_resizer.c +++ b/kernel/drivers/staging/media/omap4iss/iss_resizer.c @@ -143,7 +143,7 @@ static void resizer_set_outaddr(struct iss_resizer_device *resizer, u32 addr) informat = &resizer->formats[RESIZER_PAD_SINK]; outformat = &resizer->formats[RESIZER_PAD_SOURCE_MEM]; - /* Save address splitted in Base Address H & L */ + /* Save address split in Base Address H & L */ iss_reg_write(iss, OMAP4_ISS_MEM_ISP_RESIZER, RZA_SDR_Y_BAD_H, (addr >> 16) & 0xffff); iss_reg_write(iss, OMAP4_ISS_MEM_ISP_RESIZER, RZA_SDR_Y_BAD_L, @@ -168,7 +168,7 @@ static void resizer_set_outaddr(struct iss_resizer_device *resizer, u32 addr) c_addr |= addr & 0x7f; } - /* Save address splitted in Base Address H & L */ + /* Save address split in Base Address H & L */ iss_reg_write(iss, OMAP4_ISS_MEM_ISP_RESIZER, RZA_SDR_C_BAD_H, (c_addr >> 16) & 0xffff); iss_reg_write(iss, OMAP4_ISS_MEM_ISP_RESIZER, RZA_SDR_C_BAD_L, @@ -274,7 +274,7 @@ static void resizer_isr_buffer(struct iss_resizer_device *resizer) resizer_enable(resizer, 0); buffer = omap4iss_video_buffer_next(&resizer->video_out); - if (buffer == NULL) + if (!buffer) return; resizer_set_outaddr(resizer, buffer->iss_addr); @@ -482,7 +482,6 @@ resizer_try_format(struct iss_resizer_device *resizer, fmt->width &= ~15; fmt->height = clamp_t(u32, height, 32, fmt->height); break; - } fmt->colorspace = V4L2_COLORSPACE_JPEG; @@ -497,8 +496,8 @@ resizer_try_format(struct iss_resizer_device *resizer, * return -EINVAL or zero on success */ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_mbus_code_enum *code) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_mbus_code_enum *code) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; @@ -542,8 +541,8 @@ static int resizer_enum_mbus_code(struct v4l2_subdev *sd, } static int resizer_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; @@ -580,14 +579,15 @@ static int resizer_enum_frame_size(struct v4l2_subdev *sd, * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) +static int resizer_get_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *fmt) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; fmt->format = *format; @@ -603,14 +603,15 @@ static int resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_con * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond * to the format type. */ -static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, +static int resizer_set_format(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) { struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; format = __resizer_get_format(resizer, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; resizer_try_format(resizer, cfg, fmt->pad, &fmt->format, fmt->which); @@ -623,7 +624,7 @@ static int resizer_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_con fmt->which); *format = fmt->format; resizer_try_format(resizer, cfg, RESIZER_PAD_SOURCE_MEM, format, - fmt->which); + fmt->which); } return 0; @@ -709,8 +710,8 @@ static const struct v4l2_subdev_internal_ops resizer_v4l2_internal_ops = { * return -EINVAL or zero on success */ static int resizer_link_setup(struct media_entity *entity, - const struct media_pad *local, - const struct media_pad *remote, u32 flags) + const struct media_pad *local, + const struct media_pad *remote, u32 flags) { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); @@ -732,7 +733,6 @@ static int resizer_link_setup(struct media_entity *entity, else if (remote->entity == &iss->ipipe.subdev.entity) resizer->input = RESIZER_INPUT_IPIPE; - break; case RESIZER_PAD_SOURCE_MEM | MEDIA_ENT_T_DEVNODE: @@ -820,7 +820,7 @@ void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer) } int omap4iss_resizer_register_entities(struct iss_resizer_device *resizer, - struct v4l2_device *vdev) + struct v4l2_device *vdev) { int ret; diff --git a/kernel/drivers/staging/media/omap4iss/iss_resizer.h b/kernel/drivers/staging/media/omap4iss/iss_resizer.h index 3727498b0..1e145abaf 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_resizer.h +++ b/kernel/drivers/staging/media/omap4iss/iss_resizer.h @@ -22,7 +22,7 @@ enum resizer_input_entity { RESIZER_INPUT_IPIPEIF }; -#define RESIZER_OUTPUT_MEMORY (1 << 0) +#define RESIZER_OUTPUT_MEMORY BIT(0) /* Sink and source RESIZER pads */ #define RESIZER_PAD_SINK 0 @@ -63,13 +63,13 @@ struct iss_device; int omap4iss_resizer_init(struct iss_device *iss); void omap4iss_resizer_cleanup(struct iss_device *iss); int omap4iss_resizer_register_entities(struct iss_resizer_device *resizer, - struct v4l2_device *vdev); + struct v4l2_device *vdev); void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer); int omap4iss_resizer_busy(struct iss_resizer_device *resizer); void omap4iss_resizer_isr(struct iss_resizer_device *resizer, u32 events); void omap4iss_resizer_restore_context(struct iss_device *iss); void omap4iss_resizer_max_rate(struct iss_resizer_device *resizer, - unsigned int *max_rate); + unsigned int *max_rate); #endif /* OMAP4_ISS_RESIZER_H */ diff --git a/kernel/drivers/staging/media/omap4iss/iss_video.c b/kernel/drivers/staging/media/omap4iss/iss_video.c index 85c54fedd..2a0158bb4 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_video.c +++ b/kernel/drivers/staging/media/omap4iss/iss_video.c @@ -25,7 +25,6 @@ #include "iss_video.h" #include "iss.h" - /* ----------------------------------------------------------------------------- * Helper functions */ @@ -191,7 +190,7 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad) remote = media_entity_remote_pad(&video->pad); - if (remote == NULL || + if (!remote || media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) return NULL; @@ -241,7 +240,7 @@ __iss_video_get_format(struct iss_video *video, int ret; subdev = iss_video_remote_subdev(video, &pad); - if (subdev == NULL) + if (!subdev) return -EINVAL; memset(&fmt, 0, sizeof(fmt)); @@ -288,7 +287,7 @@ iss_video_check_format(struct iss_video *video, struct iss_video_fh *vfh) */ static int iss_video_queue_setup(struct vb2_queue *vq, - const struct v4l2_format *fmt, + const void *parg, unsigned int *count, unsigned int *num_planes, unsigned int sizes[], void *alloc_ctxs[]) { @@ -311,7 +310,8 @@ static int iss_video_queue_setup(struct vb2_queue *vq, static void iss_video_buf_cleanup(struct vb2_buffer *vb) { - struct iss_buffer *buffer = container_of(vb, struct iss_buffer, vb); + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb); if (buffer->iss_addr) buffer->iss_addr = 0; @@ -319,8 +319,9 @@ static void iss_video_buf_cleanup(struct vb2_buffer *vb) static int iss_video_buf_prepare(struct vb2_buffer *vb) { + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); - struct iss_buffer *buffer = container_of(vb, struct iss_buffer, vb); + struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb); struct iss_video *video = vfh->video; unsigned long size = vfh->format.fmt.pix.sizeimage; dma_addr_t addr; @@ -342,9 +343,10 @@ static int iss_video_buf_prepare(struct vb2_buffer *vb) static void iss_video_buf_queue(struct vb2_buffer *vb) { + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); struct iss_video_fh *vfh = vb2_get_drv_priv(vb->vb2_queue); struct iss_video *video = vfh->video; - struct iss_buffer *buffer = container_of(vb, struct iss_buffer, vb); + struct iss_buffer *buffer = container_of(vbuf, struct iss_buffer, vb); struct iss_pipeline *pipe = to_iss_pipeline(&video->video.entity); unsigned long flags; bool empty; @@ -420,7 +422,6 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) enum iss_pipeline_state state; struct iss_buffer *buf; unsigned long flags; - struct timespec ts; spin_lock_irqsave(&video->qlock, flags); if (WARN_ON(list_empty(&video->dmaqueue))) { @@ -433,9 +434,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) list_del(&buf->list); spin_unlock_irqrestore(&video->qlock, flags); - ktime_get_ts(&ts); - buf->vb.v4l2_buf.timestamp.tv_sec = ts.tv_sec; - buf->vb.v4l2_buf.timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC; + v4l2_get_timestamp(&buf->vb.timestamp); /* Do frame number propagation only if this is the output video node. * Frame number either comes from the CSI receivers or it gets @@ -444,12 +443,12 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) * first, so the input number might lag behind by 1 in some cases. */ if (video == pipe->output && !pipe->do_propagation) - buf->vb.v4l2_buf.sequence = + buf->vb.sequence = atomic_inc_return(&pipe->frame_number); else - buf->vb.v4l2_buf.sequence = atomic_read(&pipe->frame_number); + buf->vb.sequence = atomic_read(&pipe->frame_number); - vb2_buffer_done(&buf->vb, pipe->error ? + vb2_buffer_done(&buf->vb.vb2_buf, pipe->error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE); pipe->error = false; @@ -471,7 +470,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) return NULL; } - if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) { + if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input) { spin_lock(&pipe->lock); pipe->state &= ~ISS_PIPELINE_STREAM; spin_unlock(&pipe->lock); @@ -480,7 +479,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) buf = list_first_entry(&video->dmaqueue, struct iss_buffer, list); spin_unlock_irqrestore(&video->qlock, flags); - buf->vb.state = VB2_BUF_STATE_ACTIVE; + buf->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE; return buf; } @@ -503,7 +502,7 @@ void omap4iss_video_cancel_stream(struct iss_video *video) buf = list_first_entry(&video->dmaqueue, struct iss_buffer, list); list_del(&buf->list); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } vb2_queue_error(video->queue); @@ -624,7 +623,7 @@ iss_video_try_format(struct file *file, void *fh, struct v4l2_format *format) return -EINVAL; subdev = iss_video_remote_subdev(video, &pad); - if (subdev == NULL) + if (!subdev) return -EINVAL; iss_video_pix_to_mbus(&format->fmt.pix, &fmt.format); @@ -640,76 +639,6 @@ iss_video_try_format(struct file *file, void *fh, struct v4l2_format *format) } static int -iss_video_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropcap) -{ - struct iss_video *video = video_drvdata(file); - struct v4l2_subdev *subdev; - int ret; - - subdev = iss_video_remote_subdev(video, NULL); - if (subdev == NULL) - return -EINVAL; - - mutex_lock(&video->mutex); - ret = v4l2_subdev_call(subdev, video, cropcap, cropcap); - mutex_unlock(&video->mutex); - - return ret == -ENOIOCTLCMD ? -ENOTTY : ret; -} - -static int -iss_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop) -{ - struct iss_video *video = video_drvdata(file); - struct v4l2_subdev_format format; - struct v4l2_subdev *subdev; - u32 pad; - int ret; - - subdev = iss_video_remote_subdev(video, &pad); - if (subdev == NULL) - return -EINVAL; - - /* Try the get crop operation first and fallback to get format if not - * implemented. - */ - ret = v4l2_subdev_call(subdev, video, g_crop, crop); - if (ret != -ENOIOCTLCMD) - return ret; - - format.pad = pad; - format.which = V4L2_SUBDEV_FORMAT_ACTIVE; - ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &format); - if (ret < 0) - return ret == -ENOIOCTLCMD ? -ENOTTY : ret; - - crop->c.left = 0; - crop->c.top = 0; - crop->c.width = format.format.width; - crop->c.height = format.format.height; - - return 0; -} - -static int -iss_video_set_crop(struct file *file, void *fh, const struct v4l2_crop *crop) -{ - struct iss_video *video = video_drvdata(file); - struct v4l2_subdev *subdev; - int ret; - - subdev = iss_video_remote_subdev(video, NULL); - if (subdev == NULL) - return -EINVAL; - - mutex_lock(&video->mutex); - ret = v4l2_subdev_call(subdev, video, s_crop, crop); - mutex_unlock(&video->mutex); - - return ret == -ENOIOCTLCMD ? -ENOTTY : ret; -} - -static int iss_video_get_param(struct file *file, void *fh, struct v4l2_streamparm *a) { struct iss_video_fh *vfh = to_iss_video_fh(fh); @@ -876,7 +805,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) pipe->input = far_end; pipe->output = video; } else { - if (far_end == NULL) { + if (!far_end) { ret = -EPIPE; goto err_iss_video_check_format; } @@ -911,7 +840,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) * to the stream on command. In memory-to-memory mode, it will be * started when buffers are queued on both the input and output. */ - if (pipe->input == NULL) { + if (!pipe->input) { unsigned long flags; ret = omap4iss_pipeline_set_stream(pipe, @@ -1018,9 +947,6 @@ static const struct v4l2_ioctl_ops iss_video_ioctl_ops = { .vidioc_g_fmt_vid_out = iss_video_get_format, .vidioc_s_fmt_vid_out = iss_video_set_format, .vidioc_try_fmt_vid_out = iss_video_try_format, - .vidioc_cropcap = iss_video_cropcap, - .vidioc_g_crop = iss_video_get_crop, - .vidioc_s_crop = iss_video_set_crop, .vidioc_g_parm = iss_video_get_param, .vidioc_s_parm = iss_video_set_param, .vidioc_reqbufs = iss_video_reqbufs, @@ -1047,14 +973,14 @@ static int iss_video_open(struct file *file) int ret = 0; handle = kzalloc(sizeof(*handle), GFP_KERNEL); - if (handle == NULL) + if (!handle) return -ENOMEM; v4l2_fh_init(&handle->vfh, &video->video); v4l2_fh_add(&handle->vfh); /* If this is the first user, initialise the pipeline. */ - if (omap4iss_get(video->iss) == NULL) { + if (!omap4iss_get(video->iss)) { ret = -EBUSY; goto done; } @@ -1189,7 +1115,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name) mutex_init(&video->stream_lock); /* Initialize the video device. */ - if (video->ops == NULL) + if (!video->ops) video->ops = &iss_video_dummy_ops; video->video.fops = &iss_video_fops; diff --git a/kernel/drivers/staging/media/omap4iss/iss_video.h b/kernel/drivers/staging/media/omap4iss/iss_video.h index f11fce2cb..41532eda1 100644 --- a/kernel/drivers/staging/media/omap4iss/iss_video.h +++ b/kernel/drivers/staging/media/omap4iss/iss_video.h @@ -18,7 +18,7 @@ #include <media/media-entity.h> #include <media/v4l2-dev.h> #include <media/v4l2-fh.h> -#include <media/videobuf2-core.h> +#include <media/videobuf2-v4l2.h> #include <media/videobuf2-dma-contig.h> #define ISS_VIDEO_DRIVER_NAME "issvideo" @@ -117,12 +117,12 @@ static inline int iss_pipeline_ready(struct iss_pipeline *pipe) */ struct iss_buffer { /* common v4l buffer stuff -- must be first */ - struct vb2_buffer vb; + struct vb2_v4l2_buffer vb; struct list_head list; dma_addr_t iss_addr; }; -#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, buffer) +#define to_iss_buffer(buf) container_of(buf, struct iss_buffer, vb) enum iss_video_dmaqueue_flags { /* Set if DMA queue becomes empty when ISS_PIPELINE_STREAM_CONTINUOUS */ |