Commit 39857de4 authored by Joel Stanley's avatar Joel Stanley Committed by Mauro Carvalho Chehab

media: aspeed: Use runtime configuration

The aspeed video IP has some differences between SoC families. Currently
the driver decides which registers to use at compile time, which means
a single kernel can not be used between platforms.

Switch to using runtime configuration of the registers that vary between
SoC families. This is in preparation for upcoming ast2600 support.

[hverkuil: replace ;; by ;]
Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
Reviewed-by: default avatarEddie James <eajames@linux.ibm.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent aef0a509
...@@ -72,11 +72,8 @@ ...@@ -72,11 +72,8 @@
#define VE_SEQ_CTRL_CAP_BUSY BIT(16) #define VE_SEQ_CTRL_CAP_BUSY BIT(16)
#define VE_SEQ_CTRL_COMP_BUSY BIT(18) #define VE_SEQ_CTRL_COMP_BUSY BIT(18)
#ifdef CONFIG_MACH_ASPEED_G5 #define AST2500_VE_SEQ_CTRL_JPEG_MODE BIT(13)
#define VE_SEQ_CTRL_JPEG_MODE BIT(13) /* AST2500 */ #define AST2400_VE_SEQ_CTRL_JPEG_MODE BIT(8)
#else
#define VE_SEQ_CTRL_JPEG_MODE BIT(8) /* AST2400 */
#endif /* CONFIG_MACH_ASPEED_G5 */
#define VE_CTRL 0x008 #define VE_CTRL 0x008
#define VE_CTRL_HSYNC_POL BIT(0) #define VE_CTRL_HSYNC_POL BIT(0)
...@@ -220,6 +217,9 @@ struct aspeed_video { ...@@ -220,6 +217,9 @@ struct aspeed_video {
struct video_device vdev; struct video_device vdev;
struct mutex video_lock; /* v4l2 and videobuf2 lock */ struct mutex video_lock; /* v4l2 and videobuf2 lock */
u32 jpeg_mode;
u32 comp_size_read;
wait_queue_head_t wait; wait_queue_head_t wait;
spinlock_t lock; /* buffer list lock */ spinlock_t lock; /* buffer list lock */
struct delayed_work res_work; struct delayed_work res_work;
...@@ -243,6 +243,21 @@ struct aspeed_video { ...@@ -243,6 +243,21 @@ struct aspeed_video {
#define to_aspeed_video(x) container_of((x), struct aspeed_video, v4l2_dev) #define to_aspeed_video(x) container_of((x), struct aspeed_video, v4l2_dev)
struct aspeed_video_config {
u32 jpeg_mode;
u32 comp_size_read;
};
static const struct aspeed_video_config ast2400_config = {
.jpeg_mode = AST2400_VE_SEQ_CTRL_JPEG_MODE,
.comp_size_read = VE_OFFSET_COMP_STREAM,
};
static const struct aspeed_video_config ast2500_config = {
.jpeg_mode = AST2500_VE_SEQ_CTRL_JPEG_MODE,
.comp_size_read = VE_OFFSET_COMP_STREAM,
};
static const u32 aspeed_video_jpeg_header[ASPEED_VIDEO_JPEG_HEADER_SIZE] = { static const u32 aspeed_video_jpeg_header[ASPEED_VIDEO_JPEG_HEADER_SIZE] = {
0xe0ffd8ff, 0x464a1000, 0x01004649, 0x60000101, 0x00006000, 0x0f00feff, 0xe0ffd8ff, 0x464a1000, 0x01004649, 0x60000101, 0x00006000, 0x0f00feff,
0x00002d05, 0x00000000, 0x00000000, 0x00dbff00 0x00002d05, 0x00000000, 0x00000000, 0x00dbff00
...@@ -572,7 +587,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg) ...@@ -572,7 +587,7 @@ static irqreturn_t aspeed_video_irq(int irq, void *arg)
if (sts & VE_INTERRUPT_COMP_COMPLETE) { if (sts & VE_INTERRUPT_COMP_COMPLETE) {
struct aspeed_video_buffer *buf; struct aspeed_video_buffer *buf;
u32 frame_size = aspeed_video_read(video, u32 frame_size = aspeed_video_read(video,
VE_OFFSET_COMP_STREAM); video->comp_size_read);
spin_lock(&video->lock); spin_lock(&video->lock);
clear_bit(VIDEO_FRAME_INPRG, &video->flags); clear_bit(VIDEO_FRAME_INPRG, &video->flags);
...@@ -907,7 +922,7 @@ static void aspeed_video_init_regs(struct aspeed_video *video) ...@@ -907,7 +922,7 @@ static void aspeed_video_init_regs(struct aspeed_video *video)
FIELD_PREP(VE_COMP_CTRL_DCT_LUM, video->jpeg_quality) | FIELD_PREP(VE_COMP_CTRL_DCT_LUM, video->jpeg_quality) |
FIELD_PREP(VE_COMP_CTRL_DCT_CHR, video->jpeg_quality | 0x10); FIELD_PREP(VE_COMP_CTRL_DCT_CHR, video->jpeg_quality | 0x10);
u32 ctrl = VE_CTRL_AUTO_OR_CURSOR; u32 ctrl = VE_CTRL_AUTO_OR_CURSOR;
u32 seq_ctrl = VE_SEQ_CTRL_JPEG_MODE; u32 seq_ctrl = video->jpeg_mode;
if (video->frame_rate) if (video->frame_rate)
ctrl |= FIELD_PREP(VE_CTRL_FRC, video->frame_rate); ctrl |= FIELD_PREP(VE_CTRL_FRC, video->frame_rate);
...@@ -1653,8 +1668,17 @@ static int aspeed_video_init(struct aspeed_video *video) ...@@ -1653,8 +1668,17 @@ static int aspeed_video_init(struct aspeed_video *video)
return rc; return rc;
} }
static const struct of_device_id aspeed_video_of_match[] = {
{ .compatible = "aspeed,ast2400-video-engine", .data = &ast2400_config },
{ .compatible = "aspeed,ast2500-video-engine", .data = &ast2500_config },
{}
};
MODULE_DEVICE_TABLE(of, aspeed_video_of_match);
static int aspeed_video_probe(struct platform_device *pdev) static int aspeed_video_probe(struct platform_device *pdev)
{ {
const struct aspeed_video_config *config;
const struct of_device_id *match;
struct aspeed_video *video; struct aspeed_video *video;
int rc; int rc;
...@@ -1666,6 +1690,14 @@ static int aspeed_video_probe(struct platform_device *pdev) ...@@ -1666,6 +1690,14 @@ static int aspeed_video_probe(struct platform_device *pdev)
if (IS_ERR(video->base)) if (IS_ERR(video->base))
return PTR_ERR(video->base); return PTR_ERR(video->base);
match = of_match_node(aspeed_video_of_match, pdev->dev.of_node);
if (!match)
return -EINVAL;
config = match->data;
video->jpeg_mode = config->jpeg_mode;
video->comp_size_read = config->comp_size_read;
video->frame_rate = 30; video->frame_rate = 30;
video->dev = &pdev->dev; video->dev = &pdev->dev;
spin_lock_init(&video->lock); spin_lock_init(&video->lock);
...@@ -1712,13 +1744,6 @@ static int aspeed_video_remove(struct platform_device *pdev) ...@@ -1712,13 +1744,6 @@ static int aspeed_video_remove(struct platform_device *pdev)
return 0; return 0;
} }
static const struct of_device_id aspeed_video_of_match[] = {
{ .compatible = "aspeed,ast2400-video-engine" },
{ .compatible = "aspeed,ast2500-video-engine" },
{}
};
MODULE_DEVICE_TABLE(of, aspeed_video_of_match);
static struct platform_driver aspeed_video_driver = { static struct platform_driver aspeed_video_driver = {
.driver = { .driver = {
.name = DEVICE_NAME, .name = DEVICE_NAME,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment