From 03dd4cb26d967f9588437b0fc9cc0e8353322bb7 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 25 Mar 2016 03:53:42 -0300 Subject: Linux-libre 4.5-gnu --- drivers/staging/media/bcm2048/radio-bcm2048.c | 397 ++++++++++----------- drivers/staging/media/davinci_vpfe/Kconfig | 2 + drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 16 +- .../staging/media/davinci_vpfe/dm365_ipipe_hw.c | 2 +- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 17 +- drivers/staging/media/davinci_vpfe/dm365_isif.c | 17 +- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 46 +-- .../staging/media/davinci_vpfe/vpfe_mc_capture.c | 12 +- drivers/staging/media/davinci_vpfe/vpfe_video.c | 62 ++-- drivers/staging/media/davinci_vpfe/vpfe_video.h | 1 + drivers/staging/media/lirc/lirc_imon.c | 2 + drivers/staging/media/lirc/lirc_parallel.c | 35 +- drivers/staging/media/lirc/lirc_sasem.c | 20 +- drivers/staging/media/lirc/lirc_serial.c | 50 +-- drivers/staging/media/omap4iss/Kconfig | 2 +- drivers/staging/media/omap4iss/iss.c | 203 +++++++---- drivers/staging/media/omap4iss/iss.h | 10 +- drivers/staging/media/omap4iss/iss_csi2.c | 54 ++- drivers/staging/media/omap4iss/iss_csi2.h | 1 + drivers/staging/media/omap4iss/iss_csiphy.h | 2 +- drivers/staging/media/omap4iss/iss_ipipe.c | 11 +- drivers/staging/media/omap4iss/iss_ipipeif.c | 44 ++- drivers/staging/media/omap4iss/iss_ipipeif.h | 1 + drivers/staging/media/omap4iss/iss_resizer.c | 46 ++- drivers/staging/media/omap4iss/iss_resizer.h | 1 + drivers/staging/media/omap4iss/iss_video.c | 64 +++- drivers/staging/media/omap4iss/iss_video.h | 5 +- 27 files changed, 630 insertions(+), 493 deletions(-) (limited to 'drivers/staging/media') diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index b10d6016b..8fdf0ac4f 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -179,14 +179,13 @@ #define BCM2048_DEFAULT_TIMEOUT 1500 #define BCM2048_AUTO_SEARCH_TIMEOUT 3000 - #define BCM2048_FREQDEV_UNIT 10000 #define BCM2048_FREQV4L2_MULTI 625 #define dev_to_v4l2(f) ((f * BCM2048_FREQDEV_UNIT) / BCM2048_FREQV4L2_MULTI) #define v4l2_to_dev(f) ((f * BCM2048_FREQV4L2_MULTI) / BCM2048_FREQDEV_UNIT) -#define msb(x) ((u8)((u16) x >> 8)) -#define lsb(x) ((u8)((u16) x & 0x00FF)) +#define msb(x) ((u8)((u16)x >> 8)) +#define lsb(x) ((u8)((u16)x & 0x00FF)) #define compose_u16(msb, lsb) (((u16)msb << 8) | lsb) #define BCM2048_DEFAULT_POWERING_DELAY 20 @@ -348,7 +347,7 @@ static struct region_info region_configs[] = { * I2C Interface read / write */ static int bcm2048_send_command(struct bcm2048_device *bdev, unsigned int reg, - unsigned int value) + unsigned int value) { struct i2c_client *client = bdev->client; u8 data[2]; @@ -370,7 +369,7 @@ static int bcm2048_send_command(struct bcm2048_device *bdev, unsigned int reg, } static int bcm2048_recv_command(struct bcm2048_device *bdev, unsigned int reg, - u8 *value) + u8 *value) { struct i2c_client *client = bdev->client; @@ -385,7 +384,7 @@ static int bcm2048_recv_command(struct bcm2048_device *bdev, unsigned int reg, } static int bcm2048_recv_duples(struct bcm2048_device *bdev, unsigned int reg, - u8 *value, u8 duples) + u8 *value, u8 duples) { struct i2c_client *client = bdev->client; struct i2c_adapter *adap = client->adapter; @@ -436,7 +435,7 @@ static int bcm2048_set_power_state(struct bcm2048_device *bdev, u8 power) */ if (power) err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM, - bdev->cache_fm_rds_system); + bdev->cache_fm_rds_system); msleep(BCM2048_DEFAULT_POWERING_DELAY); if (!power) @@ -475,17 +474,17 @@ static int bcm2048_set_rds_no_lock(struct bcm2048_device *bdev, u8 rds_on) bdev->rds_state = BCM2048_RDS_ON; flags = BCM2048_RDS_FLAG_FIFO_WLINE; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1, - flags); + flags); } else { flags = 0; bdev->rds_state = 0; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1, - flags); + flags); memset(&bdev->rds_info, 0, sizeof(bdev->rds_info)); } err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM, - bdev->cache_fm_rds_system); + bdev->cache_fm_rds_system); return err; } @@ -545,14 +544,14 @@ static int bcm2048_set_fm_automatic_stereo_mono(struct bcm2048_device *bdev, bdev->cache_fm_ctrl |= BCM2048_STEREO_MONO_AUTO_SELECT; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL, - bdev->cache_fm_ctrl); + bdev->cache_fm_ctrl); mutex_unlock(&bdev->mutex); return err; } static int bcm2048_set_fm_hi_lo_injection(struct bcm2048_device *bdev, - u8 hi_lo) + u8 hi_lo) { int err; @@ -564,7 +563,7 @@ static int bcm2048_set_fm_hi_lo_injection(struct bcm2048_device *bdev, bdev->cache_fm_ctrl |= BCM2048_HI_LO_INJECTION; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL, - bdev->cache_fm_ctrl); + bdev->cache_fm_ctrl); mutex_unlock(&bdev->mutex); return err; @@ -592,7 +591,7 @@ static int bcm2048_set_fm_frequency(struct bcm2048_device *bdev, u32 frequency) int err; if (frequency < bdev->region_info.bottom_frequency || - frequency > bdev->region_info.top_frequency) + frequency > bdev->region_info.top_frequency) return -EDOM; frequency -= BCM2048_FREQUENCY_BASE; @@ -601,7 +600,7 @@ static int bcm2048_set_fm_frequency(struct bcm2048_device *bdev, u32 frequency) err = bcm2048_send_command(bdev, BCM2048_I2C_FM_FREQ0, lsb(frequency)); err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_FREQ1, - msb(frequency)); + msb(frequency)); if (!err) bdev->frequency = frequency; @@ -632,12 +631,12 @@ static int bcm2048_get_fm_frequency(struct bcm2048_device *bdev) } static int bcm2048_set_fm_af_frequency(struct bcm2048_device *bdev, - u32 frequency) + u32 frequency) { int err; if (frequency < bdev->region_info.bottom_frequency || - frequency > bdev->region_info.top_frequency) + frequency > bdev->region_info.top_frequency) return -EDOM; frequency -= BCM2048_FREQUENCY_BASE; @@ -645,9 +644,9 @@ static int bcm2048_set_fm_af_frequency(struct bcm2048_device *bdev, mutex_lock(&bdev->mutex); err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AF_FREQ0, - lsb(frequency)); + lsb(frequency)); err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_AF_FREQ1, - msb(frequency)); + msb(frequency)); if (!err) bdev->frequency = frequency; @@ -692,7 +691,7 @@ static int bcm2048_set_fm_deemphasis(struct bcm2048_device *bdev, int d) bdev->cache_fm_audio_ctrl0 |= deemphasis; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, - bdev->cache_fm_audio_ctrl0); + bdev->cache_fm_audio_ctrl0); if (!err) bdev->region_info.deemphasis = d; @@ -740,7 +739,7 @@ static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region) bdev->cache_fm_ctrl &= ~BCM2048_BAND_SELECT; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL, - bdev->cache_fm_ctrl); + bdev->cache_fm_ctrl); if (err) { mutex_unlock(&bdev->mutex); goto done; @@ -748,7 +747,7 @@ static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region) mutex_unlock(&bdev->mutex); if (bdev->frequency < region_configs[region].bottom_frequency || - bdev->frequency > region_configs[region].top_frequency) + bdev->frequency > region_configs[region].top_frequency) new_frequency = region_configs[region].bottom_frequency; if (new_frequency > 0) { @@ -759,7 +758,7 @@ static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region) } err = bcm2048_set_fm_deemphasis(bdev, - region_configs[region].deemphasis); + region_configs[region].deemphasis); done: return err; @@ -786,10 +785,10 @@ static int bcm2048_set_mute(struct bcm2048_device *bdev, u16 mute) if (mute) bdev->cache_fm_audio_ctrl0 |= (BCM2048_RF_MUTE | - BCM2048_MANUAL_MUTE); + BCM2048_MANUAL_MUTE); err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, - bdev->cache_fm_audio_ctrl0); + bdev->cache_fm_audio_ctrl0); if (!err) bdev->mute_state = mute; @@ -807,7 +806,7 @@ static int bcm2048_get_mute(struct bcm2048_device *bdev) if (bdev->power_state) { err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, - &value); + &value); if (!err) err = value & (BCM2048_RF_MUTE | BCM2048_MANUAL_MUTE); } else { @@ -826,11 +825,11 @@ static int bcm2048_set_audio_route(struct bcm2048_device *bdev, u8 route) route &= (BCM2048_AUDIO_ROUTE_DAC | BCM2048_AUDIO_ROUTE_I2S); bdev->cache_fm_audio_ctrl0 &= ~(BCM2048_AUDIO_ROUTE_DAC | - BCM2048_AUDIO_ROUTE_I2S); + BCM2048_AUDIO_ROUTE_I2S); bdev->cache_fm_audio_ctrl0 |= route; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, - bdev->cache_fm_audio_ctrl0); + bdev->cache_fm_audio_ctrl0); mutex_unlock(&bdev->mutex); return err; @@ -849,7 +848,7 @@ static int bcm2048_get_audio_route(struct bcm2048_device *bdev) if (!err) return value & (BCM2048_AUDIO_ROUTE_DAC | - BCM2048_AUDIO_ROUTE_I2S); + BCM2048_AUDIO_ROUTE_I2S); return err; } @@ -865,7 +864,7 @@ static int bcm2048_set_dac_output(struct bcm2048_device *bdev, u8 channels) bdev->cache_fm_audio_ctrl0 |= channels; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, - bdev->cache_fm_audio_ctrl0); + bdev->cache_fm_audio_ctrl0); mutex_unlock(&bdev->mutex); return err; @@ -884,13 +883,13 @@ static int bcm2048_get_dac_output(struct bcm2048_device *bdev) if (!err) return value & (BCM2048_DAC_OUTPUT_LEFT | - BCM2048_DAC_OUTPUT_RIGHT); + BCM2048_DAC_OUTPUT_RIGHT); return err; } static int bcm2048_set_fm_search_rssi_threshold(struct bcm2048_device *bdev, - u8 threshold) + u8 threshold) { int err; @@ -901,7 +900,7 @@ static int bcm2048_set_fm_search_rssi_threshold(struct bcm2048_device *bdev, bdev->cache_fm_search_ctrl0 |= threshold; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0, - bdev->cache_fm_search_ctrl0); + bdev->cache_fm_search_ctrl0); mutex_unlock(&bdev->mutex); return err; @@ -937,7 +936,7 @@ static int bcm2048_set_fm_search_mode_direction(struct bcm2048_device *bdev, bdev->cache_fm_search_ctrl0 |= BCM2048_SEARCH_DIRECTION; err = bcm2048_send_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0, - bdev->cache_fm_search_ctrl0); + bdev->cache_fm_search_ctrl0); mutex_unlock(&bdev->mutex); return err; @@ -961,7 +960,7 @@ static int bcm2048_get_fm_search_mode_direction(struct bcm2048_device *bdev) } static int bcm2048_set_fm_search_tune_mode(struct bcm2048_device *bdev, - u8 mode) + u8 mode) { int err, timeout, restart_rds = 0; u8 value, flags; @@ -1000,8 +999,8 @@ static int bcm2048_set_fm_search_tune_mode(struct bcm2048_device *bdev, timeout = BCM2048_AUTO_SEARCH_TIMEOUT; if (!wait_for_completion_timeout(&bdev->compl, - msecs_to_jiffies(timeout))) - dev_err(&bdev->client->dev, "IRQ timeout.\n"); + msecs_to_jiffies(timeout))) + dev_err(&bdev->client->dev, "IRQ timeout.\n"); if (value) if (!bdev->scan_state) @@ -1024,7 +1023,7 @@ static int bcm2048_get_fm_search_tune_mode(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_SEARCH_TUNE_MODE, - &value); + &value); mutex_unlock(&bdev->mutex); @@ -1040,10 +1039,10 @@ static int bcm2048_set_rds_b_block_mask(struct bcm2048_device *bdev, u16 mask) mutex_lock(&bdev->mutex); - err = bcm2048_send_command(bdev, - BCM2048_I2C_RDS_BLKB_MASK0, lsb(mask)); - err |= bcm2048_send_command(bdev, - BCM2048_I2C_RDS_BLKB_MASK1, msb(mask)); + err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MASK0, + lsb(mask)); + err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MASK1, + msb(mask)); mutex_unlock(&bdev->mutex); return err; @@ -1056,10 +1055,8 @@ static int bcm2048_get_rds_b_block_mask(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); - err = bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_BLKB_MASK0, &lsb); - err |= bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_BLKB_MASK1, &msb); + err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MASK0, &lsb); + err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MASK1, &msb); mutex_unlock(&bdev->mutex); @@ -1070,16 +1067,16 @@ static int bcm2048_get_rds_b_block_mask(struct bcm2048_device *bdev) } static int bcm2048_set_rds_b_block_match(struct bcm2048_device *bdev, - u16 match) + u16 match) { int err; mutex_lock(&bdev->mutex); - err = bcm2048_send_command(bdev, - BCM2048_I2C_RDS_BLKB_MATCH0, lsb(match)); - err |= bcm2048_send_command(bdev, - BCM2048_I2C_RDS_BLKB_MATCH1, msb(match)); + err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH0, + lsb(match)); + err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH1, + msb(match)); mutex_unlock(&bdev->mutex); return err; @@ -1092,10 +1089,8 @@ static int bcm2048_get_rds_b_block_match(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); - err = bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_BLKB_MATCH0, &lsb); - err |= bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_BLKB_MATCH1, &msb); + err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH0, &lsb); + err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH1, &msb); mutex_unlock(&bdev->mutex); @@ -1111,10 +1106,8 @@ static int bcm2048_set_rds_pi_mask(struct bcm2048_device *bdev, u16 mask) mutex_lock(&bdev->mutex); - err = bcm2048_send_command(bdev, - BCM2048_I2C_RDS_PI_MASK0, lsb(mask)); - err |= bcm2048_send_command(bdev, - BCM2048_I2C_RDS_PI_MASK1, msb(mask)); + err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MASK0, lsb(mask)); + err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MASK1, msb(mask)); mutex_unlock(&bdev->mutex); return err; @@ -1127,10 +1120,8 @@ static int bcm2048_get_rds_pi_mask(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); - err = bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_PI_MASK0, &lsb); - err |= bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_PI_MASK1, &msb); + err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MASK0, &lsb); + err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MASK1, &msb); mutex_unlock(&bdev->mutex); @@ -1146,10 +1137,10 @@ static int bcm2048_set_rds_pi_match(struct bcm2048_device *bdev, u16 match) mutex_lock(&bdev->mutex); - err = bcm2048_send_command(bdev, - BCM2048_I2C_RDS_PI_MATCH0, lsb(match)); - err |= bcm2048_send_command(bdev, - BCM2048_I2C_RDS_PI_MATCH1, msb(match)); + err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MATCH0, + lsb(match)); + err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MATCH1, + msb(match)); mutex_unlock(&bdev->mutex); return err; @@ -1162,10 +1153,8 @@ static int bcm2048_get_rds_pi_match(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); - err = bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_PI_MATCH0, &lsb); - err |= bcm2048_recv_command(bdev, - BCM2048_I2C_RDS_PI_MATCH1, &msb); + err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MATCH0, &lsb); + err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MATCH1, &msb); mutex_unlock(&bdev->mutex); @@ -1181,10 +1170,8 @@ static int bcm2048_set_fm_rds_mask(struct bcm2048_device *bdev, u16 mask) mutex_lock(&bdev->mutex); - err = bcm2048_send_command(bdev, - BCM2048_I2C_FM_RDS_MASK0, lsb(mask)); - err |= bcm2048_send_command(bdev, - BCM2048_I2C_FM_RDS_MASK1, msb(mask)); + err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK0, lsb(mask)); + err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1, msb(mask)); mutex_unlock(&bdev->mutex); return err; @@ -1245,13 +1232,13 @@ static int bcm2048_set_fm_best_tune_mode(struct bcm2048_device *bdev, u8 mode) /* Perform read as the manual indicates */ err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE, - &value); + &value); value &= ~BCM2048_BEST_TUNE_MODE; if (mode) value |= BCM2048_BEST_TUNE_MODE; err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE, - value); + value); mutex_unlock(&bdev->mutex); return err; @@ -1265,7 +1252,7 @@ static int bcm2048_get_fm_best_tune_mode(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE, - &value); + &value); mutex_unlock(&bdev->mutex); @@ -1352,7 +1339,7 @@ static int bcm2048_checkrev(struct bcm2048_device *bdev) if (!err) { dev_info(&bdev->client->dev, "BCM2048 Version 0x%x\n", - version); + version); return version; } @@ -1362,7 +1349,7 @@ static int bcm2048_checkrev(struct bcm2048_device *bdev) static int bcm2048_get_rds_rt(struct bcm2048_device *bdev, char *data) { int err = 0, i, j = 0, ce = 0, cr = 0; - char data_buffer[BCM2048_MAX_RDS_RT+1]; + char data_buffer[BCM2048_MAX_RDS_RT + 1]; mutex_lock(&bdev->mutex); @@ -1412,7 +1399,7 @@ unlock: static int bcm2048_get_rds_ps(struct bcm2048_device *bdev, char *data) { int err = 0, i, j = 0; - char data_buffer[BCM2048_MAX_RDS_PS+1]; + char data_buffer[BCM2048_MAX_RDS_PS + 1]; mutex_lock(&bdev->mutex); @@ -1448,12 +1435,10 @@ static void bcm2048_parse_rds_pi(struct bcm2048_device *bdev) u16 pi; for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) { - /* Block A match, only data without crc errors taken */ if (bdev->rds_info.radio_text[i] == BCM2048_RDS_BLOCK_A) { - - pi = (bdev->rds_info.radio_text[i+1] << 8) + - bdev->rds_info.radio_text[i+2]; + pi = (bdev->rds_info.radio_text[i + 1] << 8) + + bdev->rds_info.radio_text[i + 2]; if (!bdev->rds_info.rds_pi) { bdev->rds_info.rds_pi = pi; @@ -1478,20 +1463,21 @@ static int bcm2048_rds_block_crc(struct bcm2048_device *bdev, int i) } static void bcm2048_parse_rds_rt_block(struct bcm2048_device *bdev, int i, - int index, int crc) + int index, int crc) { /* Good data will overwrite poor data */ if (crc) { if (!bdev->rds_info.rds_rt[index]) bdev->rds_info.rds_rt[index] = - bdev->rds_info.radio_text[i+1]; - if (!bdev->rds_info.rds_rt[index+1]) - bdev->rds_info.rds_rt[index+1] = - bdev->rds_info.radio_text[i+2]; + bdev->rds_info.radio_text[i + 1]; + if (!bdev->rds_info.rds_rt[index + 1]) + bdev->rds_info.rds_rt[index + 1] = + bdev->rds_info.radio_text[i + 2]; } else { - bdev->rds_info.rds_rt[index] = bdev->rds_info.radio_text[i+1]; - bdev->rds_info.rds_rt[index+1] = - bdev->rds_info.radio_text[i+2]; + bdev->rds_info.rds_rt[index] = + bdev->rds_info.radio_text[i + 1]; + bdev->rds_info.rds_rt[index + 1] = + bdev->rds_info.radio_text[i + 2]; } } @@ -1505,18 +1491,17 @@ static int bcm2048_parse_rt_match_b(struct bcm2048_device *bdev, int i) return -EIO; if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == - BCM2048_RDS_BLOCK_B) { - - rt_id = bdev->rds_info.radio_text[i+1] & + BCM2048_RDS_BLOCK_B) { + rt_id = bdev->rds_info.radio_text[i + 1] & BCM2048_RDS_BLOCK_MASK; - rt_group_b = bdev->rds_info.radio_text[i+1] & + rt_group_b = bdev->rds_info.radio_text[i + 1] & BCM2048_RDS_GROUP_AB_MASK; - rt_ab = bdev->rds_info.radio_text[i+2] & + rt_ab = bdev->rds_info.radio_text[i + 2] & BCM2048_RDS_RT_AB_MASK; if (rt_group_b != bdev->rds_info.rds_rt_group_b) { memset(bdev->rds_info.rds_rt, 0, - sizeof(bdev->rds_info.rds_rt)); + sizeof(bdev->rds_info.rds_rt)); bdev->rds_info.rds_rt_group_b = rt_group_b; } @@ -1524,11 +1509,11 @@ static int bcm2048_parse_rt_match_b(struct bcm2048_device *bdev, int i) /* A to B or (vice versa), means: clear screen */ if (rt_ab != bdev->rds_info.rds_rt_ab) { memset(bdev->rds_info.rds_rt, 0, - sizeof(bdev->rds_info.rds_rt)); + sizeof(bdev->rds_info.rds_rt)); bdev->rds_info.rds_rt_ab = rt_ab; } - index = bdev->rds_info.radio_text[i+2] & + index = bdev->rds_info.radio_text[i + 2] & BCM2048_RDS_RT_INDEX; if (bdev->rds_info.rds_rt_group_b) @@ -1544,7 +1529,7 @@ static int bcm2048_parse_rt_match_b(struct bcm2048_device *bdev, int i) } static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i, - int index) + int index) { int crc; @@ -1567,7 +1552,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i, } static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i, - int index) + int index) { int crc; @@ -1579,8 +1564,8 @@ static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i, BUG_ON((index+4) >= BCM2048_MAX_RDS_RT); if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == - BCM2048_RDS_BLOCK_D) - bcm2048_parse_rds_rt_block(bdev, i, index+2, crc); + BCM2048_RDS_BLOCK_D) + bcm2048_parse_rds_rt_block(bdev, i, index + 2, crc); } static void bcm2048_parse_rds_rt(struct bcm2048_device *bdev) @@ -1588,7 +1573,6 @@ static void bcm2048_parse_rds_rt(struct bcm2048_device *bdev) int i, index = 0, crc, match_b = 0, match_c = 0, match_d = 0; for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) { - if (match_b) { match_b = 0; index = bcm2048_parse_rt_match_b(bdev, i); @@ -1607,40 +1591,41 @@ static void bcm2048_parse_rds_rt(struct bcm2048_device *bdev) } /* Skip erroneous blocks due to messed up A block altogether */ - if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) - == BCM2048_RDS_BLOCK_A) { + if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == + BCM2048_RDS_BLOCK_A) { crc = bcm2048_rds_block_crc(bdev, i); if (crc == BCM2048_RDS_CRC_UNRECOVARABLE) continue; - /* Syncronize to a good RDS PI */ - if (((bdev->rds_info.radio_text[i+1] << 8) + - bdev->rds_info.radio_text[i+2]) == - bdev->rds_info.rds_pi) - match_b = 1; + /* Synchronize to a good RDS PI */ + if (((bdev->rds_info.radio_text[i + 1] << 8) + + bdev->rds_info.radio_text[i + 2]) == + bdev->rds_info.rds_pi) + match_b = 1; } } } static void bcm2048_parse_rds_ps_block(struct bcm2048_device *bdev, int i, - int index, int crc) + int index, int crc) { /* Good data will overwrite poor data */ if (crc) { if (!bdev->rds_info.rds_ps[index]) bdev->rds_info.rds_ps[index] = - bdev->rds_info.radio_text[i+1]; - if (!bdev->rds_info.rds_ps[index+1]) - bdev->rds_info.rds_ps[index+1] = - bdev->rds_info.radio_text[i+2]; + bdev->rds_info.radio_text[i + 1]; + if (!bdev->rds_info.rds_ps[index + 1]) + bdev->rds_info.rds_ps[index + 1] = + bdev->rds_info.radio_text[i + 2]; } else { - bdev->rds_info.rds_ps[index] = bdev->rds_info.radio_text[i+1]; - bdev->rds_info.rds_ps[index+1] = - bdev->rds_info.radio_text[i+2]; + bdev->rds_info.rds_ps[index] = + bdev->rds_info.radio_text[i + 1]; + bdev->rds_info.rds_ps[index + 1] = + bdev->rds_info.radio_text[i + 2]; } } static int bcm2048_parse_ps_match_c(struct bcm2048_device *bdev, int i, - int index) + int index) { int crc; @@ -1650,14 +1635,14 @@ static int bcm2048_parse_ps_match_c(struct bcm2048_device *bdev, int i, return 0; if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == - BCM2048_RDS_BLOCK_C) + BCM2048_RDS_BLOCK_C) return 1; return 0; } static void bcm2048_parse_ps_match_d(struct bcm2048_device *bdev, int i, - int index) + int index) { int crc; @@ -1667,7 +1652,7 @@ static void bcm2048_parse_ps_match_d(struct bcm2048_device *bdev, int i, return; if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == - BCM2048_RDS_BLOCK_D) + BCM2048_RDS_BLOCK_D) bcm2048_parse_rds_ps_block(bdev, i, index, crc); } @@ -1682,10 +1667,10 @@ static int bcm2048_parse_ps_match_b(struct bcm2048_device *bdev, int i) /* Block B Radio PS match */ if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == - BCM2048_RDS_BLOCK_B) { - ps_id = bdev->rds_info.radio_text[i+1] & + BCM2048_RDS_BLOCK_B) { + ps_id = bdev->rds_info.radio_text[i + 1] & BCM2048_RDS_BLOCK_MASK; - ps_group = bdev->rds_info.radio_text[i+1] & + ps_group = bdev->rds_info.radio_text[i + 1] & BCM2048_RDS_GROUP_AB_MASK; /* @@ -1709,7 +1694,7 @@ static int bcm2048_parse_ps_match_b(struct bcm2048_device *bdev, int i) } if (ps_id == BCM2048_RDS_PS) { - index = bdev->rds_info.radio_text[i+2] & + index = bdev->rds_info.radio_text[i + 2] & BCM2048_RDS_PS_INDEX; index <<= 1; return index; @@ -1724,7 +1709,6 @@ static void bcm2048_parse_rds_ps(struct bcm2048_device *bdev) int i, index = 0, crc, match_b = 0, match_c = 0, match_d = 0; for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) { - if (match_b) { match_b = 0; index = bcm2048_parse_ps_match_b(bdev, i); @@ -1743,16 +1727,16 @@ static void bcm2048_parse_rds_ps(struct bcm2048_device *bdev) } /* Skip erroneous blocks due to messed up A block altogether */ - if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) - == BCM2048_RDS_BLOCK_A) { + if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) == + BCM2048_RDS_BLOCK_A) { crc = bcm2048_rds_block_crc(bdev, i); if (crc == BCM2048_RDS_CRC_UNRECOVARABLE) continue; - /* Syncronize to a good RDS PI */ - if (((bdev->rds_info.radio_text[i+1] << 8) + - bdev->rds_info.radio_text[i+2]) == - bdev->rds_info.rds_pi) - match_b = 1; + /* Synchronize to a good RDS PI */ + if (((bdev->rds_info.radio_text[i + 1] << 8) + + bdev->rds_info.radio_text[i + 2]) == + bdev->rds_info.rds_pi) + match_b = 1; } } } @@ -1764,7 +1748,7 @@ static void bcm2048_rds_fifo_receive(struct bcm2048_device *bdev) mutex_lock(&bdev->mutex); err = bcm2048_recv_duples(bdev, BCM2048_I2C_RDS_DATA, - bdev->rds_info.radio_text, bdev->fifo_size); + bdev->rds_info.radio_text, bdev->fifo_size); if (err != 2) { dev_err(&bdev->client->dev, "RDS Read problem\n"); mutex_unlock(&bdev->mutex); @@ -1801,8 +1785,8 @@ static int bcm2048_get_rds_data(struct bcm2048_device *bdev, char *data) } for (i = 0; i < bdev->rds_info.text_len; i++) { - p += sprintf(data_buffer+p, "%x ", - bdev->rds_info.radio_text[i]); + p += sprintf(data_buffer + p, "%x ", + bdev->rds_info.radio_text[i]); } memcpy(data, data_buffer, p); @@ -1829,7 +1813,7 @@ static int bcm2048_init(struct bcm2048_device *bdev) goto exit; err = bcm2048_set_dac_output(bdev, BCM2048_DAC_OUTPUT_LEFT | - BCM2048_DAC_OUTPUT_RIGHT); + BCM2048_DAC_OUTPUT_RIGHT); exit: return err; @@ -1921,7 +1905,6 @@ static void bcm2048_work(struct work_struct *work) if (flag_lsb & (BCM2048_FM_FLAG_SEARCH_TUNE_FINISHED | BCM2048_FM_FLAG_SEARCH_TUNE_FAIL)) { - if (flag_lsb & BCM2048_FM_FLAG_SEARCH_TUNE_FAIL) bdev->scan_state = BCM2048_SCAN_FAIL; else @@ -1935,7 +1918,7 @@ static void bcm2048_work(struct work_struct *work) if (bdev->rds_state) { flags = BCM2048_RDS_FLAG_FIFO_WLINE; bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1, - flags); + flags); } bdev->rds_data_available = 1; bdev->rd_index = 0; /* new data, new start */ @@ -2074,7 +2057,7 @@ property_str_read(rds_rt, (BCM2048_MAX_RDS_RT + 1)) property_str_read(rds_ps, (BCM2048_MAX_RDS_PS + 1)) property_read(fm_rds_flags, unsigned int, "%u") -property_str_read(rds_data, BCM2048_MAX_RDS_RADIO_TEXT*5) +property_str_read(rds_data, BCM2048_MAX_RDS_RADIO_TEXT * 5) property_read(region_bottom_frequency, unsigned int, "%u") property_read(region_top_frequency, unsigned int, "%u") @@ -2084,70 +2067,70 @@ DEFINE_SYSFS_PROPERTY(region, unsigned, int, "%u", 0) static struct device_attribute attrs[] = { __ATTR(power_state, S_IRUGO | S_IWUSR, bcm2048_power_state_read, - bcm2048_power_state_write), + bcm2048_power_state_write), __ATTR(mute, S_IRUGO | S_IWUSR, bcm2048_mute_read, - bcm2048_mute_write), + bcm2048_mute_write), __ATTR(audio_route, S_IRUGO | S_IWUSR, bcm2048_audio_route_read, - bcm2048_audio_route_write), + bcm2048_audio_route_write), __ATTR(dac_output, S_IRUGO | S_IWUSR, bcm2048_dac_output_read, - bcm2048_dac_output_write), + bcm2048_dac_output_write), __ATTR(fm_hi_lo_injection, S_IRUGO | S_IWUSR, - bcm2048_fm_hi_lo_injection_read, - bcm2048_fm_hi_lo_injection_write), + bcm2048_fm_hi_lo_injection_read, + bcm2048_fm_hi_lo_injection_write), __ATTR(fm_frequency, S_IRUGO | S_IWUSR, bcm2048_fm_frequency_read, - bcm2048_fm_frequency_write), + bcm2048_fm_frequency_write), __ATTR(fm_af_frequency, S_IRUGO | S_IWUSR, - bcm2048_fm_af_frequency_read, - bcm2048_fm_af_frequency_write), + bcm2048_fm_af_frequency_read, + bcm2048_fm_af_frequency_write), __ATTR(fm_deemphasis, S_IRUGO | S_IWUSR, bcm2048_fm_deemphasis_read, - bcm2048_fm_deemphasis_write), + bcm2048_fm_deemphasis_write), __ATTR(fm_rds_mask, S_IRUGO | S_IWUSR, bcm2048_fm_rds_mask_read, - bcm2048_fm_rds_mask_write), + bcm2048_fm_rds_mask_write), __ATTR(fm_best_tune_mode, S_IRUGO | S_IWUSR, - bcm2048_fm_best_tune_mode_read, - bcm2048_fm_best_tune_mode_write), + bcm2048_fm_best_tune_mode_read, + bcm2048_fm_best_tune_mode_write), __ATTR(fm_search_rssi_threshold, S_IRUGO | S_IWUSR, - bcm2048_fm_search_rssi_threshold_read, - bcm2048_fm_search_rssi_threshold_write), + bcm2048_fm_search_rssi_threshold_read, + bcm2048_fm_search_rssi_threshold_write), __ATTR(fm_search_mode_direction, S_IRUGO | S_IWUSR, - bcm2048_fm_search_mode_direction_read, - bcm2048_fm_search_mode_direction_write), + bcm2048_fm_search_mode_direction_read, + bcm2048_fm_search_mode_direction_write), __ATTR(fm_search_tune_mode, S_IRUGO | S_IWUSR, - bcm2048_fm_search_tune_mode_read, - bcm2048_fm_search_tune_mode_write), + bcm2048_fm_search_tune_mode_read, + bcm2048_fm_search_tune_mode_write), __ATTR(rds, S_IRUGO | S_IWUSR, bcm2048_rds_read, - bcm2048_rds_write), + bcm2048_rds_write), __ATTR(rds_b_block_mask, S_IRUGO | S_IWUSR, - bcm2048_rds_b_block_mask_read, - bcm2048_rds_b_block_mask_write), + bcm2048_rds_b_block_mask_read, + bcm2048_rds_b_block_mask_write), __ATTR(rds_b_block_match, S_IRUGO | S_IWUSR, - bcm2048_rds_b_block_match_read, - bcm2048_rds_b_block_match_write), + bcm2048_rds_b_block_match_read, + bcm2048_rds_b_block_match_write), __ATTR(rds_pi_mask, S_IRUGO | S_IWUSR, bcm2048_rds_pi_mask_read, - bcm2048_rds_pi_mask_write), + bcm2048_rds_pi_mask_write), __ATTR(rds_pi_match, S_IRUGO | S_IWUSR, bcm2048_rds_pi_match_read, - bcm2048_rds_pi_match_write), + bcm2048_rds_pi_match_write), __ATTR(rds_wline, S_IRUGO | S_IWUSR, bcm2048_rds_wline_read, - bcm2048_rds_wline_write), + bcm2048_rds_wline_write), __ATTR(rds_pi, S_IRUGO, bcm2048_rds_pi_read, NULL), __ATTR(rds_rt, S_IRUGO, bcm2048_rds_rt_read, NULL), __ATTR(rds_ps, S_IRUGO, bcm2048_rds_ps_read, NULL), __ATTR(fm_rds_flags, S_IRUGO, bcm2048_fm_rds_flags_read, NULL), __ATTR(region_bottom_frequency, S_IRUGO, - bcm2048_region_bottom_frequency_read, NULL), + bcm2048_region_bottom_frequency_read, NULL), __ATTR(region_top_frequency, S_IRUGO, - bcm2048_region_top_frequency_read, NULL), + bcm2048_region_top_frequency_read, NULL), __ATTR(fm_carrier_error, S_IRUGO, - bcm2048_fm_carrier_error_read, NULL), + bcm2048_fm_carrier_error_read, NULL), __ATTR(fm_rssi, S_IRUGO, - bcm2048_fm_rssi_read, NULL), + bcm2048_fm_rssi_read, NULL), __ATTR(region, S_IRUGO | S_IWUSR, bcm2048_region_read, - bcm2048_region_write), + bcm2048_region_write), __ATTR(rds_data, S_IRUGO, bcm2048_rds_data_read, NULL), }; static int bcm2048_sysfs_unregister_properties(struct bcm2048_device *bdev, - int size) + int size) { int i; @@ -2165,7 +2148,7 @@ static int bcm2048_sysfs_register_properties(struct bcm2048_device *bdev) for (i = 0; i < ARRAY_SIZE(attrs); i++) { if (device_create_file(&bdev->client->dev, &attrs[i]) != 0) { dev_err(&bdev->client->dev, - "could not register sysfs entry\n"); + "could not register sysfs entry\n"); err = -EBUSY; bcm2048_sysfs_unregister_properties(bdev, i); break; @@ -2175,7 +2158,6 @@ static int bcm2048_sysfs_register_properties(struct bcm2048_device *bdev) return err; } - static int bcm2048_fops_open(struct file *file) { struct bcm2048_device *bdev = video_drvdata(file); @@ -2197,7 +2179,7 @@ static int bcm2048_fops_release(struct file *file) } static unsigned int bcm2048_fops_poll(struct file *file, - struct poll_table_struct *pts) + struct poll_table_struct *pts) { struct bcm2048_device *bdev = video_drvdata(file); int retval = 0; @@ -2211,7 +2193,7 @@ static unsigned int bcm2048_fops_poll(struct file *file, } static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) + size_t count, loff_t *ppos) { struct bcm2048_device *bdev = video_drvdata(file); int i; @@ -2229,7 +2211,7 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, } /* interruptible_sleep_on(&bdev->read_queue); */ if (wait_event_interruptible(bdev->read_queue, - bdev->rds_data_available) < 0) { + bdev->rds_data_available) < 0) { retval = -EINTR; goto done; } @@ -2245,13 +2227,16 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf, while (i < count) { unsigned char tmpbuf[3]; - tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index+i+2]; - tmpbuf[i+1] = bdev->rds_info.radio_text[bdev->rd_index+i+1]; - tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i] & 0xf0) >> 4; - if ((bdev->rds_info.radio_text[bdev->rd_index+i] & - BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE) - tmpbuf[i+2] |= 0x80; - if (copy_to_user(buf+i, tmpbuf, 3)) { + tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index + i + 2]; + tmpbuf[i + 1] = + bdev->rds_info.radio_text[bdev->rd_index + i + 1]; + tmpbuf[i + 2] = + (bdev->rds_info.radio_text[bdev->rd_index + i] & + 0xf0) >> 4; + if ((bdev->rds_info.radio_text[bdev->rd_index + i] & + BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE) + tmpbuf[i + 2] |= 0x80; + if (copy_to_user(buf + i, tmpbuf, 3)) { retval = -EFAULT; break; } @@ -2319,7 +2304,7 @@ static struct v4l2_queryctrl bcm2048_v4l2_queryctrl[] = { }; static int bcm2048_vidioc_querycap(struct file *file, void *priv, - struct v4l2_capability *capability) + struct v4l2_capability *capability) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); @@ -2337,7 +2322,7 @@ static int bcm2048_vidioc_querycap(struct file *file, void *priv, } static int bcm2048_vidioc_g_input(struct file *filp, void *priv, - unsigned int *i) + unsigned int *i) { *i = 0; @@ -2345,7 +2330,7 @@ static int bcm2048_vidioc_g_input(struct file *filp, void *priv, } static int bcm2048_vidioc_s_input(struct file *filp, void *priv, - unsigned int i) + unsigned int i) { if (i) return -EINVAL; @@ -2354,7 +2339,7 @@ static int bcm2048_vidioc_s_input(struct file *filp, void *priv, } static int bcm2048_vidioc_queryctrl(struct file *file, void *priv, - struct v4l2_queryctrl *qc) + struct v4l2_queryctrl *qc) { int i; @@ -2369,7 +2354,7 @@ static int bcm2048_vidioc_queryctrl(struct file *file, void *priv, } static int bcm2048_vidioc_g_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) + struct v4l2_control *ctrl) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); int err = 0; @@ -2389,7 +2374,7 @@ static int bcm2048_vidioc_g_ctrl(struct file *file, void *priv, } static int bcm2048_vidioc_s_ctrl(struct file *file, void *priv, - struct v4l2_control *ctrl) + struct v4l2_control *ctrl) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); int err = 0; @@ -2417,7 +2402,7 @@ static int bcm2048_vidioc_s_ctrl(struct file *file, void *priv, } static int bcm2048_vidioc_g_audio(struct file *file, void *priv, - struct v4l2_audio *audio) + struct v4l2_audio *audio) { if (audio->index > 1) return -EINVAL; @@ -2429,7 +2414,7 @@ static int bcm2048_vidioc_g_audio(struct file *file, void *priv, } static int bcm2048_vidioc_s_audio(struct file *file, void *priv, - const struct v4l2_audio *audio) + const struct v4l2_audio *audio) { if (audio->index != 0) return -EINVAL; @@ -2438,7 +2423,7 @@ static int bcm2048_vidioc_s_audio(struct file *file, void *priv, } static int bcm2048_vidioc_g_tuner(struct file *file, void *priv, - struct v4l2_tuner *tuner) + struct v4l2_tuner *tuner) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); s8 f_error; @@ -2493,7 +2478,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv, } static int bcm2048_vidioc_s_tuner(struct file *file, void *priv, - const struct v4l2_tuner *tuner) + const struct v4l2_tuner *tuner) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); @@ -2507,7 +2492,7 @@ static int bcm2048_vidioc_s_tuner(struct file *file, void *priv, } static int bcm2048_vidioc_g_frequency(struct file *file, void *priv, - struct v4l2_frequency *freq) + struct v4l2_frequency *freq) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); int err = 0; @@ -2528,7 +2513,7 @@ static int bcm2048_vidioc_g_frequency(struct file *file, void *priv, } static int bcm2048_vidioc_s_frequency(struct file *file, void *priv, - const struct v4l2_frequency *freq) + const struct v4l2_frequency *freq) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); int err; @@ -2546,7 +2531,7 @@ static int bcm2048_vidioc_s_frequency(struct file *file, void *priv, } static int bcm2048_vidioc_s_hw_freq_seek(struct file *file, void *priv, - const struct v4l2_hw_freq_seek *seek) + const struct v4l2_hw_freq_seek *seek) { struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file)); int err; @@ -2559,7 +2544,7 @@ static int bcm2048_vidioc_s_hw_freq_seek(struct file *file, void *priv, err = bcm2048_set_fm_search_mode_direction(bdev, seek->seek_upward); err |= bcm2048_set_fm_search_tune_mode(bdev, - BCM2048_FM_AUTO_SEARCH_MODE); + BCM2048_FM_AUTO_SEARCH_MODE); return err; } @@ -2594,7 +2579,7 @@ static struct video_device bcm2048_viddev_template = { * I2C driver interface */ static int bcm2048_i2c_driver_probe(struct i2c_client *client, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { struct bcm2048_device *bdev; int err; @@ -2613,8 +2598,8 @@ static int bcm2048_i2c_driver_probe(struct i2c_client *client, if (client->irq) { err = request_irq(client->irq, - bcm2048_handler, IRQF_TRIGGER_FALLING, - client->name, bdev); + bcm2048_handler, IRQF_TRIGGER_FALLING, + client->name, bdev); if (err < 0) { dev_err(&client->dev, "Could not request IRQ\n"); goto free_bdev; diff --git a/drivers/staging/media/davinci_vpfe/Kconfig b/drivers/staging/media/davinci_vpfe/Kconfig index 4de2f0824..f40a06954 100644 --- a/drivers/staging/media/davinci_vpfe/Kconfig +++ b/drivers/staging/media/davinci_vpfe/Kconfig @@ -2,6 +2,8 @@ config VIDEO_DM365_VPFE tristate "DM365 VPFE Media Controller Capture Driver" depends on VIDEO_V4L2 && ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF depends on HAS_DMA + depends on VIDEO_V4L2_SUBDEV_API + depends on VIDEO_DAVINCI_VPBE_DISPLAY select VIDEOBUF2_DMA_CONTIG help Support for DM365 VPFE based Media Controller Capture driver. diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index b1dfa2ccc..ac78ed2f8 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1536,8 +1536,9 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, * @fse: pointer to v4l2_subdev_frame_size_enum structure. */ static int -ipipe_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) +ipipe_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; @@ -1711,8 +1712,11 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe); u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPE_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + if (!is_media_entity_v4l2_subdev(remote->entity)) + return -EINVAL; + + switch (local->index) { + case IPIPE_PAD_SINK: if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipe->input = IPIPE_INPUT_NONE; break; @@ -1725,7 +1729,7 @@ ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, ipipe->input = IPIPE_INPUT_CCDC; break; - case IPIPE_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPE_PAD_SOURCE: /* out to RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) ipipe->output = IPIPE_OUTPUT_RESIZER; @@ -1839,7 +1843,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) v4l2_ctrl_handler_setup(&ipipe->ctrls); sd->ctrl_handler = &ipipe->ctrls; - return media_entity_init(me, IPIPE_PADS_NUM, pads, 0); + return media_entity_pads_init(me, IPIPE_PADS_NUM, pads); } /* diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c index 2a3a56b88..b1d5e23ae 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c @@ -254,7 +254,7 @@ int config_ipipe_hw(struct vpfe_ipipe_device *ipipe) void __iomem *ipipe_base = ipipe->base_addr; struct v4l2_mbus_framefmt *outformat; u32 color_pat; - u32 ipipe_mode; + int ipipe_mode; u32 data_path; /* enable clock to IPIPE */ diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index 8b230541b..633d6456f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -885,9 +885,14 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct vpfe_device *vpfe = to_vpfe_device(ipipeif); + unsigned int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_DEVNODE: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case IPIPEIF_PAD_SINK: /* Single shot mode */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -896,7 +901,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input = IPIPEIF_INPUT_MEMORY; break; - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SINK | 2 << 16: /* read from isif */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -908,7 +913,7 @@ ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local, ipipeif->input = IPIPEIF_INPUT_ISIF; break; - case IPIPEIF_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SOURCE | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->output = IPIPEIF_OUTPUT_NONE; break; @@ -971,7 +976,7 @@ vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif, ipipeif->video_in.vpfe_dev = vpfe_dev; flags = 0; - ret = media_entity_create_link(&ipipeif->video_in.video_dev.entity, 0, + ret = media_create_pad_link(&ipipeif->video_in.video_dev.entity, 0, &ipipeif->subdev.entity, 0, flags); if (ret < 0) goto fail; @@ -1026,7 +1031,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif, ipipeif->output = IPIPEIF_OUTPUT_NONE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_NUM_PADS, pads, 0); + ret = media_entity_pads_init(me, IPIPEIF_NUM_PADS, pads); if (ret) goto fail; diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 80907b464..99057892d 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1707,9 +1707,14 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd); + unsigned int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case ISIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case ISIF_PAD_SINK | 2 << 16: /* read from decoder/sensor */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { isif->input = ISIF_INPUT_NONE; @@ -1720,7 +1725,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->input = ISIF_INPUT_PARALLEL; break; - case ISIF_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case ISIF_PAD_SOURCE: /* write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) isif->output = ISIF_OUTPUT_MEMORY; @@ -1728,7 +1733,7 @@ isif_link_setup(struct media_entity *entity, const struct media_pad *local, isif->output = ISIF_OUTPUT_NONE; break; - case ISIF_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case ISIF_PAD_SOURCE | 2 << 16: if (flags & MEDIA_LNK_FL_ENABLED) isif->output = ISIF_OUTPUT_IPIPEIF; else @@ -1817,7 +1822,7 @@ int vpfe_isif_register_entities(struct vpfe_isif_device *isif, isif->video_out.vpfe_dev = vpfe_dev; flags = 0; /* connect isif to video node */ - ret = media_entity_create_link(&isif->subdev.entity, 1, + ret = media_create_pad_link(&isif->subdev.entity, 1, &isif->video_out.video_dev.entity, 0, flags); if (ret < 0) @@ -2052,7 +2057,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev) isif->input = ISIF_INPUT_NONE; isif->output = ISIF_OUTPUT_NONE; me->ops = &isif_media_ops; - status = media_entity_init(me, ISIF_PADS_NUM, pads, 0); + status = media_entity_pads_init(me, ISIF_PADS_NUM, pads); if (status) goto isif_fail; isif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index acb293ed9..a91395ce9 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -63,16 +63,11 @@ resizer_calculate_line_length(u32 pix, int width, int height, if (pix == MEDIA_BUS_FMT_UYVY8_2X8 || pix == MEDIA_BUS_FMT_SGRBG12_1X12) { *line_len = width << 1; - } else if (pix == MEDIA_BUS_FMT_Y8_1X8 || - pix == MEDIA_BUS_FMT_UV8_1X8) { - *line_len = width; - *line_len_c = width; } else { - /* YUV 420 */ - /* round width to upper 32 byte boundary */ *line_len = width; *line_len_c = width; } + /* adjust the line len to be a multiple of 32 */ *line_len += 31; *line_len &= ~0x1f; @@ -1653,10 +1648,15 @@ static int resizer_link_setup(struct media_entity *entity, struct vpfe_device *vpfe_dev = to_vpfe_device(resizer); u16 ipipeif_source = vpfe_dev->vpfe_ipipeif.output; u16 ipipe_source = vpfe_dev->vpfe_ipipe.output; + unsigned int index = local->index; + + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; if (&resizer->crop_resizer.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_CROP_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_CROP_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.input = RESIZER_CROP_INPUT_NONE; @@ -1676,7 +1676,7 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; break; - case RESIZER_CROP_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case RESIZER_CROP_PAD_SOURCE | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.output = RESIZER_CROP_OUTPUT_NONE; @@ -1688,7 +1688,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->crop_resizer.output = RESIZER_A; break; - case RESIZER_CROP_PAD_SOURCE2 | MEDIA_ENT_T_V4L2_SUBDEV: + case RESIZER_CROP_PAD_SOURCE2 | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE; @@ -1704,8 +1704,8 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; } } else if (&resizer->resizer_a.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_a.input = RESIZER_INPUT_NONE; break; @@ -1715,7 +1715,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_a.input = RESIZER_INPUT_CROP_RESIZER; break; - case RESIZER_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_a.output = RESIZER_OUTPUT_NONE; break; @@ -1729,8 +1729,8 @@ static int resizer_link_setup(struct media_entity *entity, return -EINVAL; } } else if (&resizer->resizer_b.subdev == sd) { - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_b.input = RESIZER_INPUT_NONE; break; @@ -1740,7 +1740,7 @@ static int resizer_link_setup(struct media_entity *entity, resizer->resizer_b.input = RESIZER_INPUT_CROP_RESIZER; break; - case RESIZER_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE: if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->resizer_b.output = RESIZER_OUTPUT_NONE; break; @@ -1831,27 +1831,27 @@ int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer, resizer->resizer_b.video_out.vpfe_dev = vpfe_dev; /* create link between Resizer Crop----> Resizer A*/ - ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 1, + ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 1, &resizer->resizer_a.subdev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer Crop----> Resizer B*/ - ret = media_entity_create_link(&resizer->crop_resizer.subdev.entity, 2, + ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 2, &resizer->resizer_b.subdev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer A ----> video out */ - ret = media_entity_create_link(&resizer->resizer_a.subdev.entity, 1, + ret = media_create_pad_link(&resizer->resizer_a.subdev.entity, 1, &resizer->resizer_a.video_out.video_dev.entity, 0, flags); if (ret < 0) goto out_create_link; /* create link between Resizer B ----> video out */ - ret = media_entity_create_link(&resizer->resizer_b.subdev.entity, 1, + ret = media_create_pad_link(&resizer->resizer_b.subdev.entity, 1, &resizer->resizer_b.video_out.video_dev.entity, 0, flags); if (ret < 0) goto out_create_link; @@ -1915,7 +1915,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE; vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_CROP_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, RESIZER_CROP_PADS_NUM, pads); if (ret) return ret; @@ -1937,7 +1937,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_a.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_a.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; @@ -1959,7 +1959,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, vpfe_rsz->resizer_b.output = RESIZER_OUTPUT_NONE; vpfe_rsz->resizer_b.rsz_device = vpfe_rsz; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret) return ret; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index 01df0683e..ec46f366d 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -227,7 +227,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev) return 0; vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks, - sizeof(struct clock *), GFP_KERNEL); + sizeof(*vpfe_dev->clks), GFP_KERNEL); if (vpfe_dev->clks == NULL) return -ENOMEM; @@ -445,32 +445,32 @@ static int vpfe_register_entities(struct vpfe_device *vpfe_dev) /* if entity has no pads (ex: amplifier), cant establish link */ if (vpfe_dev->sd[i]->entity.num_pads) { - ret = media_entity_create_link(&vpfe_dev->sd[i]->entity, + ret = media_create_pad_link(&vpfe_dev->sd[i]->entity, 0, &vpfe_dev->vpfe_isif.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; } - ret = media_entity_create_link(&vpfe_dev->vpfe_isif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_isif.subdev.entity, 1, &vpfe_dev->vpfe_ipipeif.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, &vpfe_dev->vpfe_ipipe.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipe.subdev.entity, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipe.subdev.entity, 1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity, 0, flags); if (ret < 0) goto out_resizer_register; - ret = media_entity_create_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, + ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity, 0, flags); if (ret < 0) diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 0fdff9162..db49af902 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -88,7 +88,7 @@ vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad) { struct media_pad *remote = media_entity_remote_pad(&video->pad); - if (remote == NULL || remote->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) *pad = remote->index; @@ -127,13 +127,14 @@ __vpfe_video_get_format(struct vpfe_video_device *video, } /* make a note of pipeline details */ -static void vpfe_prepare_pipeline(struct vpfe_video_device *video) +static int vpfe_prepare_pipeline(struct vpfe_video_device *video) { + struct media_entity_graph graph; struct media_entity *entity = &video->video_dev.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct vpfe_pipeline *pipe = &video->pipe; struct vpfe_video_device *far_end = NULL; - struct media_entity_graph graph; + int ret; pipe->input_num = 0; pipe->output_num = 0; @@ -144,11 +145,16 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) pipe->outputs[pipe->output_num++] = video; mutex_lock(&mdev->graph_mutex); + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) { + mutex_unlock(&mdev->graph_mutex); + return -ENOMEM; + } media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { if (entity == &video->video_dev.entity) continue; - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity)) continue; far_end = to_vpfe_video(media_entity_to_video_device(entity)); if (far_end->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) @@ -156,7 +162,10 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device *video) else pipe->outputs[pipe->output_num++] = far_end; } + media_entity_graph_walk_cleanup(&graph); mutex_unlock(&mdev->graph_mutex); + + return 0; } /* update pipe state selected by user */ @@ -165,7 +174,9 @@ static int vpfe_update_pipe_state(struct vpfe_video_device *video) struct vpfe_pipeline *pipe = &video->pipe; int ret; - vpfe_prepare_pipeline(video); + ret = vpfe_prepare_pipeline(video); + if (ret) + return ret; /* Find out if there is any input video if yes, it is single shot. @@ -243,8 +254,7 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) /* Retrieve the source format */ pad = media_entity_remote_pad(pad); - if (pad == NULL || - pad->entity->type != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; subdev = media_entity_to_v4l2_subdev(pad->entity); @@ -277,29 +287,35 @@ static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe) */ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) { - struct media_entity_graph graph; struct media_entity *entity; struct v4l2_subdev *subdev; struct media_device *mdev; - int ret = 0; + int ret; if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS) entity = vpfe_get_input_entity(pipe->outputs[0]); else entity = &pipe->inputs[0]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + ret = media_entity_graph_walk_init(&pipe->graph, + entity->graph_obj.mdev); + if (ret) + goto out; + media_entity_graph_walk_start(&pipe->graph, entity); + while ((entity = media_entity_graph_walk_next(&pipe->graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_subdev(entity)) continue; subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 1); if (ret < 0 && ret != -ENOIOCTLCMD) break; } +out: + if (ret) + media_entity_graph_walk_cleanup(&pipe->graph); mutex_unlock(&mdev->graph_mutex); return ret; } @@ -317,7 +333,6 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe) */ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) { - struct media_entity_graph graph; struct media_entity *entity; struct v4l2_subdev *subdev; struct media_device *mdev; @@ -328,13 +343,13 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) else entity = &pipe->inputs[0]->video_dev.entity; - mdev = entity->parent; + mdev = entity->graph_obj.mdev; mutex_lock(&mdev->graph_mutex); - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(&pipe->graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { + while ((entity = media_entity_graph_walk_next(&pipe->graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_subdev(entity)) continue; subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 0); @@ -343,6 +358,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe) } mutex_unlock(&mdev->graph_mutex); + media_entity_graph_walk_cleanup(&pipe->graph); return ret ? -ETIMEDOUT : 0; } @@ -470,7 +486,7 @@ void vpfe_video_process_buffer_complete(struct vpfe_video_device *video) { struct vpfe_pipeline *pipe = &video->pipe; - v4l2_get_timestamp(&video->cur_frm->vb.timestamp); + video->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns(); 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; @@ -1078,7 +1094,7 @@ 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 void *parg, +vpfe_buffer_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) { @@ -1600,8 +1616,8 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name) spin_lock_init(&video->irqlock); spin_lock_init(&video->dma_queue_lock); mutex_init(&video->lock); - ret = media_entity_init(&video->video_dev.entity, - 1, &video->pad, 0); + ret = media_entity_pads_init(&video->video_dev.entity, + 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h index 673cefe3e..653334d53 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -52,6 +52,7 @@ enum vpfe_video_state { struct vpfe_pipeline { /* media pipeline */ struct media_pipeline *pipe; + struct media_entity_graph graph; /* state of the pipeline, continuous, * single-shot or stopped */ diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index 534b8103a..ff1926ca1 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -885,12 +885,14 @@ static int imon_probe(struct usb_interface *interface, vendor, product, ifnum, usbdev->bus->busnum, usbdev->devnum); /* Everything went fine. Just unlock and return retval (with is 0) */ + mutex_unlock(&context->ctx_lock); goto driver_unlock; unregister_lirc: lirc_unregister_driver(driver->minor); free_tx_urb: + mutex_unlock(&context->ctx_lock); usb_free_urb(tx_urb); free_rx_urb: diff --git a/drivers/staging/media/lirc/lirc_parallel.c b/drivers/staging/media/lirc/lirc_parallel.c index c1408342b..d009bcb43 100644 --- a/drivers/staging/media/lirc/lirc_parallel.c +++ b/drivers/staging/media/lirc/lirc_parallel.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -144,25 +144,22 @@ static void lirc_off(void) static unsigned int init_lirc_timer(void) { - struct timeval tv, now; + ktime_t kt, now, timeout; unsigned int level, newlevel, timeelapsed, newtimer; int count = 0; - do_gettimeofday(&tv); - tv.tv_sec++; /* wait max. 1 sec. */ + kt = ktime_get(); + /* wait max. 1 sec. */ + timeout = ktime_add_ns(kt, NSEC_PER_SEC); level = lirc_get_timer(); do { newlevel = lirc_get_timer(); if (level == 0 && newlevel != 0) count++; level = newlevel; - do_gettimeofday(&now); - } while (count < 1000 && (now.tv_sec < tv.tv_sec - || (now.tv_sec == tv.tv_sec - && now.tv_usec < tv.tv_usec))); - - timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000 - + (now.tv_usec - tv.tv_usec); + now = ktime_get(); + } while (count < 1000 && (ktime_before(now, timeout))); + timeelapsed = ktime_us_delta(now, kt); if (count >= 1000 && timeelapsed > 0) { if (default_timer == 0) { /* autodetect timer */ @@ -220,8 +217,8 @@ static void rbuf_write(int signal) static void lirc_lirc_irq_handler(void *blah) { - struct timeval tv; - static struct timeval lasttv; + ktime_t kt, delkt; + static ktime_t lastkt; static int init; long signal; int data; @@ -244,16 +241,14 @@ static void lirc_lirc_irq_handler(void *blah) #ifdef LIRC_TIMER if (init) { - do_gettimeofday(&tv); + kt = ktime_get(); - signal = tv.tv_sec - lasttv.tv_sec; - if (signal > 15) + delkt = ktime_sub(kt, lastkt); + if (ktime_compare(delkt, ktime_set(15, 0)) > 0) /* really long time */ data = PULSE_MASK; else - data = (int) (signal*1000000 + - tv.tv_usec - lasttv.tv_usec + - LIRC_SFH506_DELAY); + data = (int)(ktime_to_us(delkt) + LIRC_SFH506_DELAY); rbuf_write(data); /* space */ } else { @@ -301,7 +296,7 @@ static void lirc_lirc_irq_handler(void *blah) data = 1; rbuf_write(PULSE_BIT|data); /* pulse */ } - do_gettimeofday(&lasttv); + lastkt = ktime_get(); #else /* add your code here */ #endif diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index f2dca69c2..2218d0042 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -111,7 +112,7 @@ struct sasem_context { } tx; /* for dealing with repeat codes (wish there was a toggle bit!) */ - struct timeval presstime; + ktime_t presstime; char lastcode[8]; int codesaved; }; @@ -566,8 +567,8 @@ static void incoming_packet(struct sasem_context *context, { int len = urb->actual_length; unsigned char *buf = urb->transfer_buffer; - long ms; - struct timeval tv; + u64 ns; + ktime_t kt; if (len != 8) { dev_warn(&context->dev->dev, @@ -584,9 +585,8 @@ static void incoming_packet(struct sasem_context *context, */ /* get the time since the last button press */ - do_gettimeofday(&tv); - ms = (tv.tv_sec - context->presstime.tv_sec) * 1000 + - (tv.tv_usec - context->presstime.tv_usec) / 1000; + kt = ktime_get(); + ns = ktime_to_ns(ktime_sub(kt, context->presstime)); if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) { /* @@ -600,10 +600,9 @@ static void incoming_packet(struct sasem_context *context, * in that time and then get a false repeat of the previous * press but it is long enough for a genuine repeat */ - if ((ms < 250) && (context->codesaved != 0)) { + if ((ns < 250 * NSEC_PER_MSEC) && (context->codesaved != 0)) { memcpy(buf, &context->lastcode, 8); - context->presstime.tv_sec = tv.tv_sec; - context->presstime.tv_usec = tv.tv_usec; + context->presstime = kt; } } else { /* save the current valid code for repeats */ @@ -613,8 +612,7 @@ static void incoming_packet(struct sasem_context *context, * just for safety reasons */ context->codesaved = 1; - context->presstime.tv_sec = tv.tv_sec; - context->presstime.tv_usec = tv.tv_usec; + context->presstime = kt; } lirc_buffer_write(context->driver->rbuf, buf); diff --git a/drivers/staging/media/lirc/lirc_serial.c b/drivers/staging/media/lirc/lirc_serial.c index 64a7b2fc5..b798b311d 100644 --- a/drivers/staging/media/lirc/lirc_serial.c +++ b/drivers/staging/media/lirc/lirc_serial.c @@ -59,7 +59,7 @@ #include #include #include -#include +#include #include #include #include @@ -204,7 +204,7 @@ static struct lirc_serial hardware[] = { #define RBUF_LEN 256 -static struct timeval lasttv = {0, 0}; +static ktime_t lastkt; static struct lirc_buffer rbuf; @@ -542,10 +542,10 @@ static void frbwrite(int l) static irqreturn_t lirc_irq_handler(int i, void *blah) { - struct timeval tv; + ktime_t kt; int counter, dcd; u8 status; - long deltv; + ktime_t delkt; int data; static int last_dcd = -1; @@ -565,7 +565,7 @@ static irqreturn_t lirc_irq_handler(int i, void *blah) if ((status & hardware[type].signal_pin_change) && sense != -1) { /* get current time */ - do_gettimeofday(&tv); + kt = ktime_get(); /* New mode, written by Trent Piepho . */ @@ -594,34 +594,20 @@ static irqreturn_t lirc_irq_handler(int i, void *blah) dcd = (status & hardware[type].signal_pin) ? 1 : 0; if (dcd == last_dcd) { - pr_warn("ignoring spike: %d %d %lx %lx %lx %lx\n", - dcd, sense, - tv.tv_sec, lasttv.tv_sec, - (unsigned long)tv.tv_usec, - (unsigned long)lasttv.tv_usec); + pr_warn("ignoring spike: %d %d %llx %llx\n", + dcd, sense, ktime_to_us(kt), + ktime_to_us(lastkt)); continue; } - deltv = tv.tv_sec-lasttv.tv_sec; - if (tv.tv_sec < lasttv.tv_sec || - (tv.tv_sec == lasttv.tv_sec && - tv.tv_usec < lasttv.tv_usec)) { - pr_warn("AIEEEE: your clock just jumped backwards\n"); - pr_warn("%d %d %lx %lx %lx %lx\n", - dcd, sense, - tv.tv_sec, lasttv.tv_sec, - (unsigned long)tv.tv_usec, - (unsigned long)lasttv.tv_usec); - data = PULSE_MASK; - } else if (deltv > 15) { + delkt = ktime_sub(kt, lastkt); + if (ktime_compare(delkt, ktime_set(15, 0)) > 0) { data = PULSE_MASK; /* really long time */ if (!(dcd^sense)) { /* sanity check */ - pr_warn("AIEEEE: %d %d %lx %lx %lx %lx\n", - dcd, sense, - tv.tv_sec, lasttv.tv_sec, - (unsigned long)tv.tv_usec, - (unsigned long)lasttv.tv_usec); + pr_warn("AIEEEE: %d %d %llx %llx\n", + dcd, sense, ktime_to_us(kt), + ktime_to_us(lastkt)); /* * detecting pulse while this * MUST be a space! @@ -629,11 +615,9 @@ static irqreturn_t lirc_irq_handler(int i, void *blah) sense = sense ? 0 : 1; } } else - data = (int) (deltv*1000000 + - tv.tv_usec - - lasttv.tv_usec); + data = (int) ktime_to_us(delkt); frbwrite(dcd^sense ? data : (data|PULSE_BIT)); - lasttv = tv; + lastkt = kt; last_dcd = dcd; wake_up_interruptible(&rbuf.wait_poll); } @@ -790,7 +774,7 @@ static int set_use_inc(void *data) unsigned long flags; /* initialize timestamp */ - do_gettimeofday(&lasttv); + lastkt = ktime_get(); spin_lock_irqsave(&hardware[type].lock, flags); @@ -979,7 +963,7 @@ static int lirc_serial_resume(struct platform_device *dev) spin_lock_irqsave(&hardware[type].lock, flags); /* Enable Interrupt */ - do_gettimeofday(&lasttv); + lastkt = ktime_get(); soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI); off(); diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig index 8d4e3bd1b..46183464e 100644 --- a/drivers/staging/media/omap4iss/Kconfig +++ b/drivers/staging/media/omap4iss/Kconfig @@ -1,6 +1,6 @@ config VIDEO_OMAP4 tristate "OMAP 4 Camera support" - depends on VIDEO_V4L2=y && VIDEO_V4L2_SUBDEV_API && I2C=y && ARCH_OMAP4 + depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4 depends on HAS_DMA select MFD_SYSCON select VIDEOBUF2_DMA_CONTIG diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index aa76ccda5..30b473cfb 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -389,15 +389,15 @@ static irqreturn_t iss_isr(int irq, void *_iss) * * Return the total number of users of all video device nodes in the pipeline. */ -static int iss_pipeline_pm_use_count(struct media_entity *entity) +static int iss_pipeline_pm_use_count(struct media_entity *entity, + struct media_entity_graph *graph) { - struct media_entity_graph graph; int use = 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while ((entity = media_entity_graph_walk_next(&graph))) { - if (media_entity_type(entity) == MEDIA_ENT_T_DEVNODE) + while ((entity = media_entity_graph_walk_next(graph))) { + if (is_media_entity_v4l2_io(entity)) use += entity->use_count; } @@ -419,7 +419,7 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) { struct v4l2_subdev *subdev; - subdev = media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV + subdev = is_media_entity_v4l2_subdev(entity) ? media_entity_to_v4l2_subdev(entity) : NULL; if (entity->use_count == 0 && change > 0 && subdev) { @@ -449,29 +449,29 @@ static int iss_pipeline_pm_power_one(struct media_entity *entity, int change) * * Return 0 on success or a negative error code on failure. */ -static int iss_pipeline_pm_power(struct media_entity *entity, int change) +static int iss_pipeline_pm_power(struct media_entity *entity, int change, + struct media_entity_graph *graph) { - struct media_entity_graph graph; struct media_entity *first = entity; int ret = 0; if (!change) return 0; - media_entity_graph_walk_start(&graph, entity); + media_entity_graph_walk_start(graph, entity); - while (!ret && (entity = media_entity_graph_walk_next(&graph))) - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + while (!ret && (entity = media_entity_graph_walk_next(graph))) + if (is_media_entity_v4l2_subdev(entity)) ret = iss_pipeline_pm_power_one(entity, change); if (!ret) return 0; - media_entity_graph_walk_start(&graph, first); + media_entity_graph_walk_start(graph, first); - while ((first = media_entity_graph_walk_next(&graph)) && + while ((first = media_entity_graph_walk_next(graph)) && first != entity) - if (media_entity_type(first) != MEDIA_ENT_T_DEVNODE) + if (is_media_entity_v4l2_subdev(first)) iss_pipeline_pm_power_one(first, -change); return ret; @@ -489,23 +489,24 @@ static int iss_pipeline_pm_power(struct media_entity *entity, int change) * off is assumed to never fail. No failure can occur when the use parameter is * set to 0. */ -int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) +int omap4iss_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph) { int change = use ? 1 : -1; int ret; - mutex_lock(&entity->parent->graph_mutex); + mutex_lock(&entity->graph_obj.mdev->graph_mutex); /* Apply use count to node. */ entity->use_count += change; WARN_ON(entity->use_count < 0); /* Apply power change to connected non-nodes. */ - ret = iss_pipeline_pm_power(entity, change); + ret = iss_pipeline_pm_power(entity, change, graph); if (ret < 0) entity->use_count -= change; - mutex_unlock(&entity->parent->graph_mutex); + mutex_unlock(&entity->graph_obj.mdev->graph_mutex); return ret; } @@ -526,34 +527,48 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, int use) static int iss_pipeline_link_notify(struct media_link *link, u32 flags, unsigned int notification) { + struct media_entity_graph *graph = + &container_of(link->graph_obj.mdev, struct iss_device, + media_dev)->pm_count_graph; struct media_entity *source = link->source->entity; struct media_entity *sink = link->sink->entity; - int source_use = iss_pipeline_pm_use_count(source); - int sink_use = iss_pipeline_pm_use_count(sink); + int source_use; + int sink_use; int ret; + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH) { + ret = media_entity_graph_walk_init(graph, + link->graph_obj.mdev); + if (ret) + return ret; + } + + source_use = iss_pipeline_pm_use_count(source, graph); + sink_use = iss_pipeline_pm_use_count(sink, graph); + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && - !(link->flags & MEDIA_LNK_FL_ENABLED)) { + !(flags & MEDIA_LNK_FL_ENABLED)) { /* Powering off entities is assumed to never fail. */ - iss_pipeline_pm_power(source, -sink_use); - iss_pipeline_pm_power(sink, -source_use); + iss_pipeline_pm_power(source, -sink_use, graph); + iss_pipeline_pm_power(sink, -source_use, graph); return 0; } - if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && + if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH && (flags & MEDIA_LNK_FL_ENABLED)) { - ret = iss_pipeline_pm_power(source, sink_use); + ret = iss_pipeline_pm_power(source, sink_use, graph); if (ret < 0) return ret; - ret = iss_pipeline_pm_power(sink, source_use); + ret = iss_pipeline_pm_power(sink, source_use, graph); if (ret < 0) - iss_pipeline_pm_power(source, -sink_use); - - return ret; + iss_pipeline_pm_power(source, -sink_use, graph); } - return 0; + if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH) + media_entity_graph_walk_cleanup(graph); + + return ret; } /* ----------------------------------------------------------------------------- @@ -590,8 +605,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (!pad || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; @@ -601,13 +615,13 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, subdev = media_entity_to_v4l2_subdev(entity); ret = v4l2_subdev_call(subdev, video, s_stream, 0); if (ret < 0) { - dev_dbg(iss->dev, "%s: module stop timeout.\n", - subdev->name); + dev_warn(iss->dev, "%s: module stop timeout.\n", + subdev->name); /* If the entity failed to stopped, assume it has * crashed. Mark it as such, the ISS will be reset when * applications will release it. */ - iss->crashed |= 1U << subdev->entity.id; + media_entity_enum_set(&iss->crashed, &subdev->entity); failure = -ETIMEDOUT; } } @@ -642,7 +656,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, * pipeline won't start anyway (those entities would then likely fail to * stop, making the problem worse). */ - if (pipe->entities & iss->crashed) + if (media_entity_enum_intersects(&pipe->ent_enum, &iss->crashed)) return -EIO; spin_lock_irqsave(&pipe->lock, flags); @@ -658,8 +672,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, break; pad = media_entity_remote_pad(pad); - if (!pad || - media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) break; entity = pad->entity; @@ -763,7 +776,8 @@ static int iss_reset(struct iss_device *iss) return -ETIMEDOUT; } - iss->crashed = 0; + media_entity_enum_zero(&iss->crashed); + return 0; } @@ -1092,7 +1106,7 @@ void omap4iss_put(struct iss_device *iss) * be worth investigating whether resetting the ISP only can't * fix the problem in some cases. */ - if (iss->crashed) + if (!media_entity_enum_empty(&iss->crashed)) iss_reset(iss); iss_disable_clocks(iss); } @@ -1259,7 +1273,7 @@ static int iss_register_entities(struct iss_device *iss) goto done; } - ret = media_entity_create_link(&sensor->entity, 0, input, pad, + ret = media_create_pad_link(&sensor->entity, 0, input, pad, flags); if (ret < 0) goto done; @@ -1274,6 +1288,68 @@ done: return ret; } +/* + * iss_create_links() - Pads links creation for the subdevices + * @iss : Pointer to ISS device + * + * return negative error code or zero on success + */ +static int iss_create_links(struct iss_device *iss) +{ + int ret; + + ret = omap4iss_csi2_create_links(iss); + if (ret < 0) { + dev_err(iss->dev, "CSI2 pads links creation failed\n"); + return ret; + } + + ret = omap4iss_ipipeif_create_links(iss); + if (ret < 0) { + dev_err(iss->dev, "ISP IPIPEIF pads links creation failed\n"); + return ret; + } + + ret = omap4iss_resizer_create_links(iss); + if (ret < 0) { + dev_err(iss->dev, "ISP RESIZER pads links creation failed\n"); + return ret; + } + + /* Connect the submodules. */ + ret = media_create_pad_link( + &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE, + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE, + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, + &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, + &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0); + if (ret < 0) + return ret; + + ret = media_create_pad_link( + &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP, + &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); + if (ret < 0) + return ret; + + return 0; +}; + static void iss_cleanup_modules(struct iss_device *iss) { omap4iss_csi2_cleanup(iss); @@ -1316,41 +1392,8 @@ static int iss_initialize_modules(struct iss_device *iss) goto error_resizer; } - /* Connect the submodules. */ - ret = media_entity_create_link( - &iss->csi2a.subdev.entity, CSI2_PAD_SOURCE, - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_entity_create_link( - &iss->csi2b.subdev.entity, CSI2_PAD_SOURCE, - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_entity_create_link( - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, - &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_entity_create_link( - &iss->ipipeif.subdev.entity, IPIPEIF_PAD_SOURCE_VP, - &iss->ipipe.subdev.entity, IPIPE_PAD_SINK, 0); - if (ret < 0) - goto error_link; - - ret = media_entity_create_link( - &iss->ipipe.subdev.entity, IPIPE_PAD_SOURCE_VP, - &iss->resizer.subdev.entity, RESIZER_PAD_SINK, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap4iss_resizer_cleanup(iss); error_resizer: omap4iss_ipipe_cleanup(iss); error_ipipe: @@ -1464,10 +1507,21 @@ static int iss_probe(struct platform_device *pdev) if (ret < 0) goto error_modules; + ret = media_entity_enum_init(&iss->crashed, &iss->media_dev); + if (ret) + goto error_entities; + + ret = iss_create_links(iss); + if (ret < 0) + goto error_entities; + omap4iss_put(iss); return 0; +error_entities: + iss_unregister_entities(iss); + media_entity_enum_cleanup(&iss->crashed); error_modules: iss_cleanup_modules(iss); error_iss: @@ -1485,6 +1539,7 @@ static int iss_remove(struct platform_device *pdev) struct iss_device *iss = platform_get_drvdata(pdev); iss_unregister_entities(iss); + media_entity_enum_cleanup(&iss->crashed); iss_cleanup_modules(iss); return 0; diff --git a/drivers/staging/media/omap4iss/iss.h b/drivers/staging/media/omap4iss/iss.h index 35df8b470..05f08a3ca 100644 --- a/drivers/staging/media/omap4iss/iss.h +++ b/drivers/staging/media/omap4iss/iss.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include "iss_regs.h" #include "iss_csiphy.h" @@ -82,11 +82,12 @@ struct iss_reg { /* * struct iss_device - ISS device structure. * @syscon: Regmap for the syscon register space - * @crashed: Bitmask of crashed entities (indexed by entity ID) + * @crashed: Crashed entities */ struct iss_device { struct v4l2_device v4l2_dev; struct media_device media_dev; + struct media_entity_graph pm_count_graph; struct device *dev; u32 revision; @@ -101,7 +102,7 @@ struct iss_device { u64 raw_dmamask; struct mutex iss_mutex; /* For handling ref_count field */ - unsigned int crashed; + struct media_entity_enum crashed; int has_context; int ref_count; @@ -151,7 +152,8 @@ void omap4iss_isp_subclk_enable(struct iss_device *iss, void omap4iss_isp_subclk_disable(struct iss_device *iss, enum iss_isp_subclk_resource res); -int omap4iss_pipeline_pm_use(struct media_entity *entity, int use); +int omap4iss_pipeline_pm_use(struct media_entity *entity, int use, + struct media_entity_graph *graph); int omap4iss_register_entities(struct platform_device *pdev, struct v4l2_device *v4l2_dev); diff --git a/drivers/staging/media/omap4iss/iss_csi2.c b/drivers/staging/media/omap4iss/iss_csi2.c index c6e6d47ac..aaca39d75 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.c +++ b/drivers/staging/media/omap4iss/iss_csi2.c @@ -674,6 +674,9 @@ static void csi2_isr_ctx(struct iss_csi2_device *csi2, status = iss_reg_read(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n)); iss_reg_write(csi2->iss, csi2->regs1, CSI2_CTX_IRQSTATUS(n), status); + if (omap4iss_module_sync_is_stopping(&csi2->wait, &csi2->stopping)) + return; + /* Propagate frame number */ if (status & CSI2_CTX_IRQ_FS) { struct iss_pipeline *pipe = @@ -776,9 +779,6 @@ void omap4iss_csi2_isr(struct iss_csi2_device *csi2) pipe->error = true; } - if (omap4iss_module_sync_is_stopping(&csi2->wait, &csi2->stopping)) - return; - /* Successful cases */ if (csi2_irqstatus & CSI2_IRQ_CONTEXT0) csi2_isr_ctx(csi2, &csi2->contexts[0]); @@ -1170,14 +1170,19 @@ static int csi2_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_csi2_device *csi2 = v4l2_get_subdevdata(sd); struct iss_csi2_ctrl_cfg *ctrl = &csi2->ctrl; + unsigned int index = local->index; + + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; /* * The ISS core doesn't support pipelines with multiple video outputs. * Revisit this when it will be implemented, and return -EBUSY for now. */ - switch (local->index | media_entity_type(remote->entity)) { - case CSI2_PAD_SOURCE | MEDIA_ENT_T_DEVNODE: + switch (index) { + case CSI2_PAD_SOURCE: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_MEMORY) return -EBUSY; @@ -1187,7 +1192,7 @@ static int csi2_link_setup(struct media_entity *entity, } break; - case CSI2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV: + case CSI2_PAD_SOURCE | 2 << 16: if (flags & MEDIA_LNK_FL_ENABLED) { if (csi2->output & ~CSI2_OUTPUT_IPIPEIF) return -EBUSY; @@ -1271,7 +1276,7 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; me->ops = &csi2_media_ops; - ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; @@ -1290,16 +1295,8 @@ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) if (ret < 0) goto error_video; - /* Connect the CSI2 subdev to the video node. */ - ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, - &csi2->video_out.video.entity, 0, 0); - if (ret < 0) - goto error_link; - return 0; -error_link: - omap4iss_video_cleanup(&csi2->video_out); error_video: media_entity_cleanup(&csi2->subdev.entity); return ret; @@ -1341,6 +1338,33 @@ int omap4iss_csi2_init(struct iss_device *iss) return 0; } +/* + * omap4iss_csi2_create_links() - CSI2 pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_csi2_create_links(struct iss_device *iss) +{ + struct iss_csi2_device *csi2a = &iss->csi2a; + struct iss_csi2_device *csi2b = &iss->csi2b; + int ret; + + /* Connect the CSI2a subdev to the video node. */ + ret = media_create_pad_link(&csi2a->subdev.entity, CSI2_PAD_SOURCE, + &csi2a->video_out.video.entity, 0, 0); + if (ret < 0) + return ret; + + /* Connect the CSI2b subdev to the video node. */ + ret = media_create_pad_link(&csi2b->subdev.entity, CSI2_PAD_SOURCE, + &csi2b->video_out.video.entity, 0, 0); + if (ret < 0) + return ret; + + return 0; +} + /* * omap4iss_csi2_cleanup - Routine for module driver cleanup */ diff --git a/drivers/staging/media/omap4iss/iss_csi2.h b/drivers/staging/media/omap4iss/iss_csi2.h index f2f5343b4..24ab378d4 100644 --- a/drivers/staging/media/omap4iss/iss_csi2.h +++ b/drivers/staging/media/omap4iss/iss_csi2.h @@ -151,6 +151,7 @@ struct iss_csi2_device { void omap4iss_csi2_isr(struct iss_csi2_device *csi2); int omap4iss_csi2_reset(struct iss_csi2_device *csi2); int omap4iss_csi2_init(struct iss_device *iss); +int omap4iss_csi2_create_links(struct iss_device *iss); void omap4iss_csi2_cleanup(struct iss_device *iss); void omap4iss_csi2_unregister_entities(struct iss_csi2_device *csi2); int omap4iss_csi2_register_entities(struct iss_csi2_device *csi2, diff --git a/drivers/staging/media/omap4iss/iss_csiphy.h b/drivers/staging/media/omap4iss/iss_csiphy.h index e9ca43955..a0f2d974d 100644 --- a/drivers/staging/media/omap4iss/iss_csiphy.h +++ b/drivers/staging/media/omap4iss/iss_csiphy.h @@ -14,7 +14,7 @@ #ifndef OMAP4_ISS_CSI_PHY_H #define OMAP4_ISS_CSI_PHY_H -#include +#include struct iss_csi2_device; diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c b/drivers/staging/media/omap4iss/iss_ipipe.c index dd0abeffd..d38782e8e 100644 --- a/drivers/staging/media/omap4iss/iss_ipipe.c +++ b/drivers/staging/media/omap4iss/iss_ipipe.c @@ -447,8 +447,11 @@ static int ipipe_link_setup(struct media_entity *entity, struct iss_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(ipipe); - switch (local->index | media_entity_type(remote->entity)) { - case IPIPE_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + if (!is_media_entity_v4l2_subdev(remote->entity)) + return -EINVAL; + + switch (local->index) { + case IPIPE_PAD_SINK: /* Read from IPIPEIF. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipe->input = IPIPE_INPUT_NONE; @@ -463,7 +466,7 @@ static int ipipe_link_setup(struct media_entity *entity, break; - case IPIPE_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPE_PAD_SOURCE_VP: /* Send to RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipe->output & ~IPIPE_OUTPUT_VP) @@ -513,7 +516,7 @@ static int ipipe_init_entities(struct iss_ipipe_device *ipipe) pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipe_media_ops; - ret = media_entity_init(me, IPIPE_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, IPIPE_PADS_NUM, pads); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c b/drivers/staging/media/omap4iss/iss_ipipeif.c index 5f9e449e7..23de83307 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.c +++ b/drivers/staging/media/omap4iss/iss_ipipeif.c @@ -662,9 +662,14 @@ static int ipipeif_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(ipipeif); + unsigned int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case IPIPEIF_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case IPIPEIF_PAD_SINK | 2 << 16: /* Read from the sensor CSI2a or CSI2b. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { ipipeif->input = IPIPEIF_INPUT_NONE; @@ -681,7 +686,7 @@ static int ipipeif_link_setup(struct media_entity *entity, break; - case IPIPEIF_PAD_SOURCE_ISIF_SF | MEDIA_ENT_T_DEVNODE: + case IPIPEIF_PAD_SOURCE_ISIF_SF: /* Write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipeif->output & ~IPIPEIF_OUTPUT_MEMORY) @@ -692,7 +697,7 @@ static int ipipeif_link_setup(struct media_entity *entity, } break; - case IPIPEIF_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV: + case IPIPEIF_PAD_SOURCE_VP | 2 << 16: /* Send to IPIPE/RESIZER */ if (flags & MEDIA_LNK_FL_ENABLED) { if (ipipeif->output & ~IPIPEIF_OUTPUT_VP) @@ -743,7 +748,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipeif_media_ops; - ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, IPIPEIF_PADS_NUM, pads); if (ret < 0) return ret; @@ -757,18 +762,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) ipipeif->video_out.bpl_zero_padding = 1; ipipeif->video_out.bpl_max = 0x1ffe0; - ret = omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF"); - if (ret < 0) - return ret; - - /* Connect the IPIPEIF subdev to the video node. */ - ret = media_entity_create_link(&ipipeif->subdev.entity, - IPIPEIF_PAD_SOURCE_ISIF_SF, - &ipipeif->video_out.video.entity, 0, 0); - if (ret < 0) - return ret; - - return 0; + return omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF"); } void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif) @@ -820,6 +814,22 @@ int omap4iss_ipipeif_init(struct iss_device *iss) return ipipeif_init_entities(ipipeif); } +/* + * omap4iss_ipipeif_create_links() - IPIPEIF pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_ipipeif_create_links(struct iss_device *iss) +{ + struct iss_ipipeif_device *ipipeif = &iss->ipipeif; + + /* Connect the IPIPEIF subdev to the video node. */ + return media_create_pad_link(&ipipeif->subdev.entity, + IPIPEIF_PAD_SOURCE_ISIF_SF, + &ipipeif->video_out.video.entity, 0, 0); +} + /* * omap4iss_ipipeif_cleanup - IPIPEIF module cleanup. * @iss: Device pointer specific to the OMAP4 ISS. diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.h b/drivers/staging/media/omap4iss/iss_ipipeif.h index c6bd96d96..bad32b1d6 100644 --- a/drivers/staging/media/omap4iss/iss_ipipeif.h +++ b/drivers/staging/media/omap4iss/iss_ipipeif.h @@ -78,6 +78,7 @@ struct iss_ipipeif_device { struct iss_device; int omap4iss_ipipeif_init(struct iss_device *iss); +int omap4iss_ipipeif_create_links(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); diff --git a/drivers/staging/media/omap4iss/iss_resizer.c b/drivers/staging/media/omap4iss/iss_resizer.c index 9c8180bba..f1d352c71 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.c +++ b/drivers/staging/media/omap4iss/iss_resizer.c @@ -158,8 +158,8 @@ static void resizer_set_outaddr(struct iss_resizer_device *resizer, u32 addr) /* Program UV buffer address... Hardcoded to be contiguous! */ if ((informat->code == MEDIA_BUS_FMT_UYVY8_1X16) && (outformat->code == MEDIA_BUS_FMT_YUYV8_1_5X8)) { - u32 c_addr = addr + (resizer->video_out.bpl_value * - (outformat->height - 1)); + u32 c_addr = addr + resizer->video_out.bpl_value + * outformat->height; /* Ensure Y_BAD_L[6:0] = C_BAD_L[6:0]*/ if ((c_addr ^ addr) & 0x7f) { @@ -716,9 +716,14 @@ static int resizer_link_setup(struct media_entity *entity, struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct iss_resizer_device *resizer = v4l2_get_subdevdata(sd); struct iss_device *iss = to_iss_device(resizer); + unsigned int index = local->index; - switch (local->index | media_entity_type(remote->entity)) { - case RESIZER_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV: + /* FIXME: this is actually a hack! */ + if (is_media_entity_v4l2_subdev(remote->entity)) + index |= 2 << 16; + + switch (index) { + case RESIZER_PAD_SINK | 2 << 16: /* Read from IPIPE or IPIPEIF. */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { resizer->input = RESIZER_INPUT_NONE; @@ -735,7 +740,7 @@ static int resizer_link_setup(struct media_entity *entity, break; - case RESIZER_PAD_SOURCE_MEM | MEDIA_ENT_T_DEVNODE: + case RESIZER_PAD_SOURCE_MEM: /* Write to memory */ if (flags & MEDIA_LNK_FL_ENABLED) { if (resizer->output & ~RESIZER_OUTPUT_MEMORY) @@ -785,7 +790,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) pads[RESIZER_PAD_SOURCE_MEM].flags = MEDIA_PAD_FL_SOURCE; me->ops = &resizer_media_ops; - ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); + ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads); if (ret < 0) return ret; @@ -799,18 +804,7 @@ static int resizer_init_entities(struct iss_resizer_device *resizer) resizer->video_out.bpl_zero_padding = 1; resizer->video_out.bpl_max = 0x1ffe0; - ret = omap4iss_video_init(&resizer->video_out, "ISP resizer a"); - if (ret < 0) - return ret; - - /* Connect the RESIZER subdev to the video node. */ - ret = media_entity_create_link(&resizer->subdev.entity, - RESIZER_PAD_SOURCE_MEM, - &resizer->video_out.video.entity, 0, 0); - if (ret < 0) - return ret; - - return 0; + return omap4iss_video_init(&resizer->video_out, "ISP resizer a"); } void omap4iss_resizer_unregister_entities(struct iss_resizer_device *resizer) @@ -862,6 +856,22 @@ int omap4iss_resizer_init(struct iss_device *iss) return resizer_init_entities(resizer); } +/* + * omap4iss_resizer_create_links() - RESIZER pads links creation + * @iss: Pointer to ISS device + * + * return negative error code or zero on success + */ +int omap4iss_resizer_create_links(struct iss_device *iss) +{ + struct iss_resizer_device *resizer = &iss->resizer; + + /* Connect the RESIZER subdev to the video node. */ + return media_create_pad_link(&resizer->subdev.entity, + RESIZER_PAD_SOURCE_MEM, + &resizer->video_out.video.entity, 0, 0); +} + /* * omap4iss_resizer_cleanup - RESIZER module cleanup. * @iss: Device pointer specific to the OMAP4 ISS. diff --git a/drivers/staging/media/omap4iss/iss_resizer.h b/drivers/staging/media/omap4iss/iss_resizer.h index 1e145abaf..8b7c5fe9f 100644 --- a/drivers/staging/media/omap4iss/iss_resizer.h +++ b/drivers/staging/media/omap4iss/iss_resizer.h @@ -61,6 +61,7 @@ struct iss_resizer_device { struct iss_device; int omap4iss_resizer_init(struct iss_device *iss); +int omap4iss_resizer_create_links(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); diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c index 2a0158bb4..058233a9d 100644 --- a/drivers/staging/media/omap4iss/iss_video.c +++ b/drivers/staging/media/omap4iss/iss_video.c @@ -190,8 +190,7 @@ iss_video_remote_subdev(struct iss_video *video, u32 *pad) remote = media_entity_remote_pad(&video->pad); - if (!remote || - media_entity_type(remote->entity) != MEDIA_ENT_T_V4L2_SUBDEV) + if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) return NULL; if (pad) @@ -206,17 +205,23 @@ iss_video_far_end(struct iss_video *video) { struct media_entity_graph graph; struct media_entity *entity = &video->video.entity; - struct media_device *mdev = entity->parent; + struct media_device *mdev = entity->graph_obj.mdev; struct iss_video *far_end = NULL; mutex_lock(&mdev->graph_mutex); + + if (media_entity_graph_walk_init(&graph, mdev)) { + mutex_unlock(&mdev->graph_mutex); + return NULL; + } + media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) { if (entity == &video->video.entity) continue; - if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE) + if (!is_media_entity_v4l2_io(entity)) continue; far_end = to_iss_video(media_entity_to_video_device(entity)); @@ -227,6 +232,9 @@ iss_video_far_end(struct iss_video *video) } mutex_unlock(&mdev->graph_mutex); + + media_entity_graph_walk_cleanup(&graph); + return far_end; } @@ -287,7 +295,6 @@ iss_video_check_format(struct iss_video *video, struct iss_video_fh *vfh) */ static int iss_video_queue_setup(struct vb2_queue *vq, - const void *parg, unsigned int *count, unsigned int *num_planes, unsigned int sizes[], void *alloc_ctxs[]) { @@ -434,7 +441,7 @@ struct iss_buffer *omap4iss_video_buffer_next(struct iss_video *video) list_del(&buf->list); spin_unlock_irqrestore(&video->qlock, flags); - v4l2_get_timestamp(&buf->vb.timestamp); + buf->vb.vb2_buf.timestamp = ktime_get_ns(); /* Do frame number propagation only if this is the output video node. * Frame number either comes from the CSI receivers or it gets @@ -751,7 +758,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) struct iss_video_fh *vfh = to_iss_video_fh(fh); struct iss_video *video = video_drvdata(file); struct media_entity_graph graph; - struct media_entity *entity; + struct media_entity *entity = &video->video.entity; enum iss_pipeline_state state; struct iss_pipeline *pipe; struct iss_video *far_end; @@ -766,24 +773,30 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) /* Start streaming on the pipeline. No link touching an entity in the * pipeline can be activated or deactivated once streaming is started. */ - pipe = video->video.entity.pipe - ? to_iss_pipeline(&video->video.entity) : &video->pipe; + pipe = entity->pipe + ? to_iss_pipeline(entity) : &video->pipe; pipe->external = NULL; pipe->external_rate = 0; pipe->external_bpp = 0; - pipe->entities = 0; + + ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev); + if (ret) + goto err_graph_walk_init; + + ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev); + if (ret) + goto err_graph_walk_init; if (video->iss->pdata->set_constraints) video->iss->pdata->set_constraints(video->iss, true); - ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); + ret = media_entity_pipeline_start(entity, &pipe->pipe); if (ret < 0) goto err_media_entity_pipeline_start; - entity = &video->video.entity; media_entity_graph_walk_start(&graph, entity); while ((entity = media_entity_graph_walk_next(&graph))) - pipe->entities |= 1 << entity->id; + media_entity_enum_set(&pipe->ent_enum, entity); /* Verify that the currently configured format matches the output of * the connected subdev. @@ -853,7 +866,10 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) spin_unlock_irqrestore(&video->qlock, flags); } + media_entity_graph_walk_cleanup(&graph); + mutex_unlock(&video->stream_lock); + return 0; err_omap4iss_set_stream: @@ -865,7 +881,13 @@ err_media_entity_pipeline_start: video->iss->pdata->set_constraints(video->iss, false); video->queue = NULL; + media_entity_graph_walk_cleanup(&graph); + +err_graph_walk_init: + media_entity_enum_cleanup(&pipe->ent_enum); + mutex_unlock(&video->stream_lock); + return ret; } @@ -903,6 +925,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) vb2_streamoff(&vfh->queue, type); video->queue = NULL; + media_entity_enum_cleanup(&pipe->ent_enum); + if (video->iss->pdata->set_constraints) video->iss->pdata->set_constraints(video->iss, false); media_entity_pipeline_stop(&video->video.entity); @@ -985,7 +1009,13 @@ static int iss_video_open(struct file *file) goto done; } - ret = omap4iss_pipeline_pm_use(&video->video.entity, 1); + ret = media_entity_graph_walk_init(&handle->graph, + &video->iss->media_dev); + if (ret) + goto done; + + ret = omap4iss_pipeline_pm_use(&video->video.entity, 1, + &handle->graph); if (ret < 0) { omap4iss_put(video->iss); goto done; @@ -1024,6 +1054,7 @@ static int iss_video_open(struct file *file) done: if (ret < 0) { v4l2_fh_del(&handle->vfh); + media_entity_graph_walk_cleanup(&handle->graph); kfree(handle); } @@ -1039,12 +1070,13 @@ static int iss_video_release(struct file *file) /* Disable streaming and free the buffers queue resources. */ iss_video_streamoff(file, vfh, video->type); - omap4iss_pipeline_pm_use(&video->video.entity, 0); + omap4iss_pipeline_pm_use(&video->video.entity, 0, &handle->graph); /* Release the videobuf2 queue */ vb2_queue_release(&handle->queue); /* Release the file handle. */ + media_entity_graph_walk_cleanup(&handle->graph); v4l2_fh_del(vfh); kfree(handle); file->private_data = NULL; @@ -1103,7 +1135,7 @@ int omap4iss_video_init(struct iss_video *video, const char *name) return -EINVAL; } - ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); + ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); if (ret < 0) return ret; diff --git a/drivers/staging/media/omap4iss/iss_video.h b/drivers/staging/media/omap4iss/iss_video.h index 41532eda1..34588b717 100644 --- a/drivers/staging/media/omap4iss/iss_video.h +++ b/drivers/staging/media/omap4iss/iss_video.h @@ -77,7 +77,7 @@ enum iss_pipeline_state { /* * struct iss_pipeline - An OMAP4 ISS hardware pipeline - * @entities: Bitmask of entities in the pipeline (indexed by entity ID) + * @ent_enum: Entities in the pipeline * @error: A hardware error occurred during capture */ struct iss_pipeline { @@ -87,7 +87,7 @@ struct iss_pipeline { enum iss_pipeline_stream_state stream_state; struct iss_video *input; struct iss_video *output; - unsigned int entities; + struct media_entity_enum ent_enum; atomic_t frame_number; bool do_propagation; /* of frame number */ bool error; @@ -183,6 +183,7 @@ struct iss_video_fh { struct vb2_queue queue; struct v4l2_format format; struct v4l2_fract timeperframe; + struct media_entity_graph graph; }; #define to_iss_video_fh(fh) container_of(fh, struct iss_video_fh, vfh) -- cgit v1.2.3-54-g00ecf