Skip to content

Commit 469a730

Browse files
committed
media: atomisp: change the detection of ISP2401 at runtime
Instead of having a static var to detect it, let's use the already-existing arch-specific bytes, as this is how other parts of the code also checks when it needs to do something different, depending on an specific chipset version. Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 77bdaca commit 469a730

File tree

17 files changed

+108
-114
lines changed

17 files changed

+108
-114
lines changed

drivers/staging/media/atomisp/include/linux/atomisp.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
#define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW 0x800b
7171
#endif
7272

73-
/* FIXME: for now, let's use a boolean to identify the type of atomisp chipset */
74-
extern bool atomisp_hw_is_isp2401;
75-
7673
/* Configuration used by Bayer noise reduction and YCC noise reduction */
7774
struct atomisp_nr_config {
7875
/* [gain] Strength of noise reduction for Bayer NR (Used by Bayer NR) */

drivers/staging/media/atomisp/include/linux/atomisp_platform.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define ATOMISP_PLATFORM_H_
2020

2121
#include <asm/intel-family.h>
22+
#include <asm/processor.h>
2223

2324
#include <linux/i2c.h>
2425
#include <linux/sfi.h>
@@ -240,11 +241,19 @@ const struct atomisp_camera_caps *atomisp_get_default_camera_caps(void);
240241
/* API from old platform_camera.h, new CPUID implementation */
241242
#define __IS_SOC(x) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
242243
boot_cpu_data.x86 == 6 && \
243-
boot_cpu_data.x86_model == x)
244+
boot_cpu_data.x86_model == (x))
245+
#define __IS_SOCS(x,y) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
246+
boot_cpu_data.x86 == 6 && \
247+
(boot_cpu_data.x86_model == (x) || \
248+
boot_cpu_data.x86_model == (y)))
244249

245250
#define IS_MFLD __IS_SOC(INTEL_FAM6_ATOM_SALTWELL_MID)
246251
#define IS_BYT __IS_SOC(INTEL_FAM6_ATOM_SILVERMONT)
247252
#define IS_CHT __IS_SOC(INTEL_FAM6_ATOM_AIRMONT)
248253
#define IS_MOFD __IS_SOC(INTEL_FAM6_ATOM_AIRMONT_MID)
249254

255+
/* Both CHT and MOFD come with ISP2401 */
256+
#define IS_ISP2401 __IS_SOCS(INTEL_FAM6_ATOM_AIRMONT, \
257+
INTEL_FAM6_ATOM_AIRMONT_MID)
258+
250259
#endif /* ATOMISP_PLATFORM_H_ */

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
989989
break;
990990
case IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME:
991991
case IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
992-
if (atomisp_hw_is_isp2401)
992+
if (IS_ISP2401)
993993
reset_wdt_timer = true;
994994

995995
pipe->buffers_in_css--;
@@ -1038,18 +1038,18 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
10381038

10391039
asd->pending_capture_request--;
10401040

1041-
if (atomisp_hw_is_isp2401)
1041+
if (IS_ISP2401)
10421042
asd->re_trigger_capture = false;
10431043

10441044
dev_dbg(isp->dev, "Trigger capture again for new buffer. err=%d\n",
10451045
err);
1046-
} else if (atomisp_hw_is_isp2401) {
1046+
} else if (IS_ISP2401) {
10471047
asd->re_trigger_capture = true;
10481048
}
10491049
break;
10501050
case IA_CSS_BUFFER_TYPE_OUTPUT_FRAME:
10511051
case IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
1052-
if (atomisp_hw_is_isp2401)
1052+
if (IS_ISP2401)
10531053
reset_wdt_timer = true;
10541054

10551055
pipe->buffers_in_css--;
@@ -1219,7 +1219,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
12191219
*/
12201220
wake_up(&vb->done);
12211221
}
1222-
if (atomisp_hw_is_isp2401)
1222+
if (IS_ISP2401)
12231223
atomic_set(&pipe->wdt_count, 0);
12241224

12251225
/*
@@ -1239,7 +1239,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
12391239
if (!error && q_buffers)
12401240
atomisp_qbuffers_to_css(asd);
12411241

1242-
if (atomisp_hw_is_isp2401) {
1242+
if (IS_ISP2401) {
12431243
/* If there are no buffers queued then
12441244
* delete wdt timer. */
12451245
if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
@@ -1475,7 +1475,7 @@ void atomisp_wdt_work(struct work_struct *work)
14751475
return;
14761476
}
14771477

1478-
if (!atomisp_hw_is_isp2401) {
1478+
if (!IS_ISP2401) {
14791479
dev_err(isp->dev, "timeout %d of %d\n",
14801480
atomic_read(&isp->wdt_count) + 1,
14811481
ATOMISP_ISP_MAX_TIMEOUT_COUNT);
@@ -1598,11 +1598,11 @@ void atomisp_wdt_work(struct work_struct *work)
15981598
atomisp_flush_bufs_and_wakeup(asd);
15991599
complete(&asd->init_done);
16001600
}
1601-
if (atomisp_hw_is_isp2401)
1601+
if (IS_ISP2401)
16021602
atomisp_wdt_stop(asd, false);
16031603
}
16041604

1605-
if (!atomisp_hw_is_isp2401) {
1605+
if (!IS_ISP2401) {
16061606
atomic_set(&isp->wdt_count, 0);
16071607
} else {
16081608
isp->isp_fatal_error = true;
@@ -1614,7 +1614,7 @@ void atomisp_wdt_work(struct work_struct *work)
16141614
}
16151615

16161616
__atomisp_css_recover(isp, true);
1617-
if (atomisp_hw_is_isp2401) {
1617+
if (IS_ISP2401) {
16181618
for (i = 0; i < isp->num_of_streams; i++) {
16191619
struct atomisp_sub_device *asd = &isp->asd[i];
16201620

@@ -1671,7 +1671,7 @@ void atomisp_wdt(struct timer_list *t)
16711671
struct atomisp_sub_device *asd;
16721672
struct atomisp_device *isp;
16731673

1674-
if (!atomisp_hw_is_isp2401) {
1674+
if (!IS_ISP2401) {
16751675
asd = from_timer(asd, t, wdt);
16761676
isp = asd->isp;
16771677
} else {
@@ -1730,7 +1730,7 @@ void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
17301730

17311731
void atomisp_wdt_refresh(struct atomisp_sub_device *asd, unsigned int delay)
17321732
{
1733-
if (!atomisp_hw_is_isp2401) {
1733+
if (!IS_ISP2401) {
17341734
unsigned long next;
17351735

17361736
if (delay != ATOMISP_WDT_KEEP_CURRENT_DELAY)
@@ -1793,7 +1793,7 @@ void atomisp_wdt_stop(struct atomisp_sub_device *asd, bool sync)
17931793
{
17941794
dev_dbg(asd->isp->dev, "WDT stop:\n");
17951795

1796-
if (!atomisp_hw_is_isp2401) {
1796+
if (!IS_ISP2401) {
17971797
if (sync) {
17981798
del_timer_sync(&asd->wdt);
17991799
cancel_work_sync(&asd->isp->wdt_work);
@@ -3014,7 +3014,7 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
30143014
* map real crop region base on above calculating base max crop region.
30153015
*/
30163016

3017-
if (!atomisp_hw_is_isp2401) {
3017+
if (!IS_ISP2401) {
30183018
dz_config->zoom_region.origin.x = dz_config->zoom_region.origin.x
30193019
* eff_res.width
30203020
/ asd->sensor_array_res.width;
@@ -3584,7 +3584,7 @@ int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
35843584
if (!from_user && css_param->update_flag.shading_table)
35853585
return 0;
35863586

3587-
if (atomisp_hw_is_isp2401) {
3587+
if (IS_ISP2401) {
35883588
if (copy_from_compatible(&dest_st, source_st,
35893589
sizeof(struct atomisp_shading_table),
35903590
from_user)) {
@@ -3617,7 +3617,7 @@ int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
36173617
}
36183618

36193619
/* Shading table size per color */
3620-
if (!atomisp_hw_is_isp2401) {
3620+
if (!IS_ISP2401) {
36213621
if (st->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
36223622
st->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
36233623
dev_err(asd->isp->dev, "shading table w/h validate failed!");
@@ -3700,7 +3700,7 @@ int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
37003700
if (!from_user && css_param->update_flag.dvs2_coefs)
37013701
return 0;
37023702

3703-
if (!atomisp_hw_is_isp2401) {
3703+
if (!IS_ISP2401) {
37043704
if (sizeof(*cur) != sizeof(coefs->grid) ||
37053705
memcmp(&coefs->grid, cur, sizeof(coefs->grid))) {
37063706
dev_err(asd->isp->dev, "dvs grid mis-match!\n");
@@ -3843,7 +3843,7 @@ int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
38433843
old_6axis_config = css_param->dvs_6axis;
38443844
dvs_6axis_config = old_6axis_config;
38453845

3846-
if (atomisp_hw_is_isp2401) {
3846+
if (IS_ISP2401) {
38473847
struct ia_css_dvs_6axis_config t_6axis_config;
38483848

38493849
if (copy_from_compatible(&t_6axis_config, source_6axis_config,
@@ -3978,7 +3978,7 @@ int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
39783978

39793979
old_morph_table = css_param->morph_table;
39803980

3981-
if (atomisp_hw_is_isp2401) {
3981+
if (IS_ISP2401) {
39823982
struct ia_css_morph_table mtbl;
39833983

39843984
if (copy_from_compatible(&mtbl, source_morph_table,
@@ -4168,7 +4168,7 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
41684168

41694169
atomisp_qbuffers_to_css(asd);
41704170

4171-
if (!atomisp_hw_is_isp2401) {
4171+
if (!IS_ISP2401) {
41724172
if (!atomisp_is_wdt_running(asd) && atomisp_buffers_queued(asd))
41734173
atomisp_wdt_start(asd);
41744174
} else {
@@ -4204,7 +4204,7 @@ int atomisp_set_parameters(struct video_device *vdev,
42044204
__func__, arg->per_frame_setting, asd->index,
42054205
arg->isp_config_id, vdev->name);
42064206

4207-
if (atomisp_hw_is_isp2401) {
4207+
if (IS_ISP2401) {
42084208
if (atomisp_is_vf_pipe(pipe) && arg->per_frame_setting) {
42094209
dev_err(asd->isp->dev, "%s: vf pipe not support per_frame_setting",
42104210
__func__);
@@ -5070,7 +5070,7 @@ static int __enable_continuous_mode(struct atomisp_sub_device *asd,
50705070
enable, asd->continuous_raw_buffer_size->val,
50715071
!asd->continuous_viewfinder->val);
50725072

5073-
if (!atomisp_hw_is_isp2401)
5073+
if (!IS_ISP2401)
50745074
atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_PRIMARY);
50755075
else
50765076
atomisp_update_capture_mode(asd);
@@ -5961,7 +5961,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
59615961
* which appears to be related by a hardware
59625962
* performance limitation. It's unclear why this
59635963
* particular code triggers the issue. */
5964-
if (!atomisp_hw_is_isp2401 || crop_needs_override) {
5964+
if (!IS_ISP2401 || crop_needs_override) {
59655965
if (isp_sink_crop.width * main_compose.height >
59665966
isp_sink_crop.height * main_compose.width) {
59675967
sink_crop.height = isp_sink_crop.height;
@@ -6107,7 +6107,7 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
61076107
}
61086108

61096109
/* Shading table size per color */
6110-
if (!atomisp_hw_is_isp2401) {
6110+
if (!IS_ISP2401) {
61116111
if (user_shading_table->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
61126112
user_shading_table->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
61136113
return -EINVAL;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ extern int pad_h;
4444
/* ISP2401 */
4545
#define ATOMISP_CSS_ISP_PIPE_VERSION_2_7 1
4646

47-
#define IS_ISP2401(isp) \
48-
(((isp)->media_dev.hw_revision & ATOMISP_HW_REVISION_MASK) \
49-
>= (ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT))
50-
5147
struct atomisp_format_bridge {
5248
unsigned int pixelformat;
5349
unsigned int depth;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ static void __apply_additional_pipe_config(
612612
default_capture_config.mode == IA_CSS_CAPTURE_MODE_RAW)
613613
stream_env->pipe_configs[pipe_id].enable_dz = false;
614614

615-
if (atomisp_hw_is_isp2401) {
615+
if (IS_ISP2401) {
616616
/* the isp default to use ISP2.2 and the camera hal will
617617
* control whether use isp2.7 */
618618
if (asd->select_isp_version->val == ATOMISP_CSS_ISP_PIPE_VERSION_2_7)
@@ -4159,7 +4159,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
41594159
for (i = 0; i < isp->num_of_streams; i++)
41604160
atomisp_wdt_stop(&isp->asd[i], 0);
41614161

4162-
if (!atomisp_hw_is_isp2401)
4162+
if (!IS_ISP2401)
41634163
atomisp_wdt(&isp->asd[0].wdt);
41644164
else
41654165
queue_work(isp->wdt_work_queue, &isp->wdt_work);
@@ -4193,7 +4193,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
41934193
atomisp_buf_done(asd, 0, IA_CSS_BUFFER_TYPE_OUTPUT_FRAME,
41944194
current_event.pipe, true, stream_id);
41954195

4196-
if (!atomisp_hw_is_isp2401)
4196+
if (!IS_ISP2401)
41974197
reset_wdt_timer[asd->index] = true; /* ISP running */
41984198

41994199
break;
@@ -4203,7 +4203,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
42034203
atomisp_buf_done(asd, 0, IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME,
42044204
current_event.pipe, true, stream_id);
42054205

4206-
if (!atomisp_hw_is_isp2401)
4206+
if (!IS_ISP2401)
42074207
reset_wdt_timer[asd->index] = true; /* ISP running */
42084208

42094209
break;
@@ -4227,7 +4227,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
42274227
IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME,
42284228
current_event.pipe, true, stream_id);
42294229

4230-
if (!atomisp_hw_is_isp2401)
4230+
if (!IS_ISP2401)
42314231
reset_wdt_timer[asd->index] = true; /* ISP running */
42324232

42334233
break;
@@ -4236,7 +4236,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
42364236
atomisp_buf_done(asd, 0,
42374237
IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME,
42384238
current_event.pipe, true, stream_id);
4239-
if (!atomisp_hw_is_isp2401)
4239+
if (!IS_ISP2401)
42404240
reset_wdt_timer[asd->index] = true; /* ISP running */
42414241

42424242
break;
@@ -4262,7 +4262,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
42624262
}
42634263
}
42644264

4265-
if (atomisp_hw_is_isp2401)
4265+
if (IS_ISP2401)
42664266
return 0;
42674267

42684268
/* ISP2400: If there are no buffers queued then delete wdt timer. */

0 commit comments

Comments
 (0)