Skip to content

Commit 401e0e4

Browse files
jwrdegoedemchehab
authored andcommitted
media: atomisp: Drop support for streaming from 2 sensors at once
With support for depth mode gone there really is no need to support streaming from 2 sensors at once. As discussed and acked on the list (see Link tag) it is desirable to drop support for this since it involves quite a lot of special handling / hacks in the code. This initial commit limits itself to a minimum set of changes to switch to 1 struct atomisp_sub_device / 1 stream. Further commits will actually remove / cleanup much of the special handling. Likewise this initial commit also deliberately skips the opportunity to turn some multi-line statements into single-line statements, so as to keep the diff small / easier to review. Link: https://lore.kernel.org/linux-media/5309d845-063b-6dd9-529d-0f82654290f2@redhat.com/ Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent df1697f commit 401e0e4

8 files changed

Lines changed: 148 additions & 305 deletions

File tree

drivers/staging/media/atomisp/pci/atomisp_cmd.c

Lines changed: 46 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
196196
enum atomisp_dfs_mode mode,
197197
bool force)
198198
{
199-
/* FIXME! Only use subdev[0] status yet */
200-
struct atomisp_sub_device *asd = &isp->asd[0];
201199
const struct atomisp_dfs_config *dfs;
202200
unsigned int new_freq;
203201
struct atomisp_freq_scaling_rule curr_rules;
@@ -223,18 +221,18 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
223221
goto done;
224222
}
225223

226-
fps = atomisp_get_sensor_fps(asd);
224+
fps = atomisp_get_sensor_fps(&isp->asd);
227225
if (fps == 0) {
228226
dev_info(isp->dev,
229227
"Sensor didn't report FPS. Using DFS max mode.\n");
230228
new_freq = dfs->highest_freq;
231229
goto done;
232230
}
233231

234-
curr_rules.width = asd->fmt[asd->capture_pad].fmt.width;
235-
curr_rules.height = asd->fmt[asd->capture_pad].fmt.height;
232+
curr_rules.width = isp->asd.fmt[isp->asd.capture_pad].fmt.width;
233+
curr_rules.height = isp->asd.fmt[isp->asd.capture_pad].fmt.height;
236234
curr_rules.fps = fps;
237-
curr_rules.run_mode = asd->run_mode->val;
235+
curr_rules.run_mode = isp->asd.run_mode->val;
238236

239237
/* search for the target frequency by looping freq rules*/
240238
for (i = 0; i < dfs->dfs_table_size; i++) {
@@ -451,37 +449,13 @@ static void clear_irq_reg(struct atomisp_device *isp)
451449
pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg_ret);
452450
}
453451

454-
static struct atomisp_sub_device *
455-
__get_asd_from_port(struct atomisp_device *isp, enum mipi_port_id port)
456-
{
457-
int i;
458-
459-
/* Check which isp subdev to send eof */
460-
for (i = 0; i < isp->num_of_streams; i++) {
461-
struct atomisp_sub_device *asd = &isp->asd[i];
462-
struct camera_mipi_info *mipi_info;
463-
464-
mipi_info = atomisp_to_sensor_mipi_info(
465-
isp->inputs[asd->input_curr].camera);
466-
467-
if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
468-
__get_mipi_port(isp, mipi_info->port) == port) {
469-
return asd;
470-
}
471-
}
472-
473-
return NULL;
474-
}
475-
476452
/* interrupt handling function*/
477453
irqreturn_t atomisp_isr(int irq, void *dev)
478454
{
479455
struct atomisp_device *isp = (struct atomisp_device *)dev;
480-
struct atomisp_sub_device *asd;
481456
struct atomisp_css_event eof_event;
482457
unsigned int irq_infos = 0;
483458
unsigned long flags;
484-
unsigned int i;
485459
int err;
486460

487461
spin_lock_irqsave(&isp->lock, flags);
@@ -501,18 +475,10 @@ irqreturn_t atomisp_isr(int irq, void *dev)
501475
if (!atomisp_streaming_count(isp))
502476
goto out_nowake;
503477

504-
for (i = 0; i < isp->num_of_streams; i++) {
505-
asd = &isp->asd[i];
506-
507-
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
508-
continue;
509-
/*
510-
* Current SOF only support one stream, so the SOF only valid
511-
* either solely one stream is running
512-
*/
478+
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
513479
if (irq_infos & IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
514-
atomic_inc(&asd->sof_count);
515-
atomisp_sof_event(asd);
480+
atomic_inc(&isp->asd.sof_count);
481+
atomisp_sof_event(&isp->asd);
516482

517483
/* If sequence_temp and sequence are the same
518484
* there where no frames lost so we can increase
@@ -522,14 +488,14 @@ irqreturn_t atomisp_isr(int irq, void *dev)
522488
* NOTE: There is assumption here that ISP will not
523489
* start processing next frame from sensor before old
524490
* one is completely done. */
525-
if (atomic_read(&asd->sequence) == atomic_read(
526-
&asd->sequence_temp))
527-
atomic_set(&asd->sequence_temp,
528-
atomic_read(&asd->sof_count));
491+
if (atomic_read(&isp->asd.sequence) ==
492+
atomic_read(&isp->asd.sequence_temp))
493+
atomic_set(&isp->asd.sequence_temp,
494+
atomic_read(&isp->asd.sof_count));
529495
}
530496
if (irq_infos & IA_CSS_IRQ_INFO_EVENTS_READY)
531-
atomic_set(&asd->sequence,
532-
atomic_read(&asd->sequence_temp));
497+
atomic_set(&isp->asd.sequence,
498+
atomic_read(&isp->asd.sequence_temp));
533499
}
534500

535501
if (irq_infos & IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
@@ -554,21 +520,12 @@ irqreturn_t atomisp_isr(int irq, void *dev)
554520
}
555521

556522
if (irq_infos & IA_CSS_IRQ_INFO_ISYS_EVENTS_READY) {
557-
while (ia_css_dequeue_isys_event(&eof_event.event) ==
558-
0) {
559-
/* EOF Event does not have the css_pipe returned */
560-
asd = __get_asd_from_port(isp, eof_event.event.port);
561-
if (!asd) {
562-
dev_err(isp->dev, "%s: ISYS event, but no subdev.event:%d",
563-
__func__, eof_event.event.type);
564-
continue;
565-
}
566-
567-
atomisp_eof_event(asd, eof_event.event.exp_id);
523+
while (ia_css_dequeue_isys_event(&eof_event.event) == 0) {
524+
atomisp_eof_event(&isp->asd, eof_event.event.exp_id);
568525
dev_dbg_ratelimited(isp->dev,
569526
"%s ISYS event: EOF exp_id %d, asd %d\n",
570527
__func__, eof_event.event.exp_id,
571-
asd->index);
528+
isp->asd.index);
572529
}
573530

574531
irq_infos &= ~IA_CSS_IRQ_INFO_ISYS_EVENTS_READY;
@@ -993,9 +950,9 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
993950
{
994951
struct pci_dev *pdev = to_pci_dev(isp->dev);
995952
enum ia_css_pipe_id css_pipe_id;
996-
bool stream_restart[MAX_STREAM_NUM] = {0};
953+
bool stream_restart = false;
997954
unsigned long flags;
998-
int i, ret;
955+
int ret;
999956

1000957
lockdep_assert_held(&isp->mutex);
1001958

@@ -1004,44 +961,37 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
1004961

1005962
atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF, false);
1006963

1007-
BUG_ON(isp->num_of_streams > MAX_STREAM_NUM);
1008-
1009-
for (i = 0; i < isp->num_of_streams; i++) {
1010-
struct atomisp_sub_device *asd = &isp->asd[i];
1011-
1012-
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED &&
1013-
!asd->stream_prepared)
1014-
continue;
1015-
1016-
stream_restart[asd->index] = true;
964+
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED ||
965+
isp->asd.stream_prepared) {
966+
stream_restart = true;
1017967

1018968
spin_lock_irqsave(&isp->lock, flags);
1019-
asd->streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
969+
isp->asd.streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
1020970
spin_unlock_irqrestore(&isp->lock, flags);
1021971

1022972
/* stream off sensor */
1023973
ret = v4l2_subdev_call(
1024-
isp->inputs[asd->input_curr].
974+
isp->inputs[isp->asd.input_curr].
1025975
camera, video, s_stream, 0);
1026976
if (ret)
1027977
dev_warn(isp->dev,
1028978
"can't stop streaming on sensor!\n");
1029979

1030-
atomisp_clear_css_buffer_counters(asd);
980+
atomisp_clear_css_buffer_counters(&isp->asd);
1031981

1032-
css_pipe_id = atomisp_get_css_pipe_id(asd);
1033-
atomisp_css_stop(asd, css_pipe_id, true);
982+
css_pipe_id = atomisp_get_css_pipe_id(&isp->asd);
983+
atomisp_css_stop(&isp->asd, css_pipe_id, true);
1034984

1035985
spin_lock_irqsave(&isp->lock, flags);
1036-
asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
986+
isp->asd.streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
1037987
spin_unlock_irqrestore(&isp->lock, flags);
1038988

1039-
asd->preview_exp_id = 1;
1040-
asd->postview_exp_id = 1;
989+
isp->asd.preview_exp_id = 1;
990+
isp->asd.postview_exp_id = 1;
1041991
/* notify HAL the CSS reset */
1042992
dev_dbg(isp->dev,
1043-
"send reset event to %s\n", asd->subdev.devnode->name);
1044-
atomisp_reset_event(asd);
993+
"send reset event to %s\n", isp->asd.subdev.devnode->name);
994+
atomisp_reset_event(&isp->asd);
1045995
}
1046996

1047997
/* clear irq */
@@ -1057,25 +1007,20 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
10571007
atomisp_reset(isp);
10581008
isp->isp_timeout = false;
10591009

1060-
for (i = 0; i < isp->num_of_streams; i++) {
1061-
struct atomisp_sub_device *asd = &isp->asd[i];
1062-
1063-
if (!stream_restart[i])
1064-
continue;
1010+
if (stream_restart) {
1011+
atomisp_css_input_set_mode(&isp->asd, IA_CSS_INPUT_MODE_BUFFERED_SENSOR);
10651012

1066-
atomisp_css_input_set_mode(asd, IA_CSS_INPUT_MODE_BUFFERED_SENSOR);
1067-
1068-
css_pipe_id = atomisp_get_css_pipe_id(asd);
1069-
if (atomisp_css_start(asd, css_pipe_id, true)) {
1013+
css_pipe_id = atomisp_get_css_pipe_id(&isp->asd);
1014+
if (atomisp_css_start(&isp->asd, css_pipe_id, true)) {
10701015
dev_warn(isp->dev,
10711016
"start SP failed, so do not set streaming to be enable!\n");
10721017
} else {
10731018
spin_lock_irqsave(&isp->lock, flags);
1074-
asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
1019+
isp->asd.streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
10751020
spin_unlock_irqrestore(&isp->lock, flags);
10761021
}
10771022

1078-
atomisp_csi2_configure(asd);
1023+
atomisp_csi2_configure(&isp->asd);
10791024
}
10801025

10811026
atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF,
@@ -1084,27 +1029,20 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
10841029
if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_AUTO, true) < 0)
10851030
dev_dbg(isp->dev, "DFS auto failed while recovering!\n");
10861031

1087-
for (i = 0; i < isp->num_of_streams; i++) {
1088-
struct atomisp_sub_device *asd;
1089-
1090-
asd = &isp->asd[i];
1091-
1092-
if (!stream_restart[i])
1093-
continue;
1094-
1032+
if (stream_restart) {
10951033
/*
10961034
* dequeueing buffers is not needed. CSS will recycle
10971035
* buffers that it has.
10981036
*/
1099-
atomisp_flush_bufs_and_wakeup(asd);
1037+
atomisp_flush_bufs_and_wakeup(&isp->asd);
11001038

11011039
/* Requeue unprocessed per-frame parameters. */
1102-
atomisp_recover_params_queue(&asd->video_out_capture);
1103-
atomisp_recover_params_queue(&asd->video_out_preview);
1104-
atomisp_recover_params_queue(&asd->video_out_video_capture);
1040+
atomisp_recover_params_queue(&isp->asd.video_out_capture);
1041+
atomisp_recover_params_queue(&isp->asd.video_out_preview);
1042+
atomisp_recover_params_queue(&isp->asd.video_out_video_capture);
11051043

11061044
ret = v4l2_subdev_call(
1107-
isp->inputs[asd->input_curr].camera, video,
1045+
isp->inputs[isp->asd.input_curr].camera, video,
11081046
s_stream, 1);
11091047
if (ret)
11101048
dev_warn(isp->dev,
@@ -1164,10 +1102,6 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)
11641102
{
11651103
struct atomisp_device *isp = isp_ptr;
11661104
unsigned long flags;
1167-
bool frame_done_found[MAX_STREAM_NUM] = {0};
1168-
bool css_pipe_done[MAX_STREAM_NUM] = {0};
1169-
unsigned int i;
1170-
struct atomisp_sub_device *asd;
11711105

11721106
dev_dbg(isp->dev, ">%s\n", __func__);
11731107

@@ -1206,15 +1140,11 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)
12061140
* time, instead, dequue one and process one, then another
12071141
*/
12081142
mutex_lock(&isp->mutex);
1209-
if (atomisp_css_isr_thread(isp, frame_done_found, css_pipe_done))
1143+
if (atomisp_css_isr_thread(isp))
12101144
goto out;
12111145

1212-
for (i = 0; i < isp->num_of_streams; i++) {
1213-
asd = &isp->asd[i];
1214-
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
1215-
continue;
1216-
atomisp_setup_flash(asd);
1217-
}
1146+
if (isp->asd.streaming == ATOMISP_DEVICE_STREAMING_ENABLED)
1147+
atomisp_setup_flash(&isp->asd);
12181148
out:
12191149
mutex_unlock(&isp->mutex);
12201150
dev_dbg(isp->dev, "<%s\n", __func__);

drivers/staging/media/atomisp/pci/atomisp_compat.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,7 @@ int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
416416

417417
int atomisp_css_update_stream(struct atomisp_sub_device *asd);
418418

419-
int atomisp_css_isr_thread(struct atomisp_device *isp,
420-
bool *frame_done_found,
421-
bool *css_pipe_done);
419+
int atomisp_css_isr_thread(struct atomisp_device *isp);
422420

423421
bool atomisp_css_valid_sof(struct atomisp_device *isp);
424422

0 commit comments

Comments
 (0)